如何在服务器控件属性中使用 ASP.NET <%= 标签?

2

本文介绍了如何在服务器控件属性中使用 ASP.NET <%= 标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

这行得通:

<span value="<%= this.Text %>" />

这不起作用:

<asp:Label Text="<%= this.Text %>" runat="server" />

这是为什么呢?

如何使第二种情况正常工作,即将标签的文本设置为文本"变量的值?

How can I make the second case work properly, i.e., set the label's text to the value of the "Text" variable?

推荐答案

不知道如何标记,但这有点重复.查看此线程.

Not sure how to mark this as such, but this is a bit of a duplicate. See this thread.

我认为将代码嵌入到您的标记中不会真正使您的标记更清晰或更优雅.

I don't think embedding code in to your markup will really make your markup any clearer or more elegant.

这篇关于如何在服务器控件属性中使用 ASP.NET &lt;%= 标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

函数委托与函数
Func Delegate vs Function(函数委托与函数)...
2023-11-11 C#/.NET开发问题
6

针对委托检查 MethodInfo
Checking a MethodInfo against a delegate(针对委托检查 MethodInfo)...
2023-11-11 C#/.NET开发问题
7

如何从 lambda 表达式中获取引用实例的实例
How to get the instance of a referred instance from a lambda expression(如何从 lambda 表达式中获取引用实例的实例)...
2023-11-11 C#/.NET开发问题
4

如何为具有空目标的实例方法创建委托?
How to create a delegate to an instance method with a null target?(如何为具有空目标的实例方法创建委托?)...
2023-11-11 C#/.NET开发问题
6