如何使用ASP.NET<%=标签服务器控件的属性? [英] How to use ASP.NET <%= tags in server control attributes?

查看:216
本文介绍了如何使用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?

推荐答案

不知道如何将这个标记为这样的,但是这是一个有点重复的。 <一href=\"http://stackoverflow.com/questions/370201/why-will-ex$p$pssions-as-property-values-on-a-server-controls-lead-to-a-compile\">See这个线程。

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

只是为了雪上加霜,我不认为嵌入code到您的标记将真正使您的标记更清楚或更优雅。 :)

Just to add insult to injury, I don't think embedding code in to your markup will really make your markup any clearer or more elegant. :)

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆