以下几点有什么区别?您是否确实需要ASP.NET标签中的Text属性?
<asp:Label runat="server">Hello World</asp:Label>
<asp:Label runat="server" Text="Hello World"></asp:Label>
更新:
如果它们是完全一样的,那么为什么使用单值数据绑定和显示transactionCount正确的值时,确实
<asp:Label ID="Label1" runat="server">
There were <%#transactionCount%> transactions today
</asp:Label>
绑定正确,同时...
<asp:Label ID="Label1" runat="server" Text="There were <%#transactionCount%> transactions today">
</asp:Label>
在页面中没有显示transactionCount的值?
再次更新:
我理解的点正在取得有关使用文字对照。我会相应地拍我的脸 - 但它仍然不能解决问题 - 尽管也许正在接近解决方案。
如果我使用...
<asp:Literal ID="Label1" runat="server" Text="<%#transactionCount%>"></asp:Literal>
...我看到transactionCount的价值在网页中显示出来。
另一方面,如果我把任何字符或单词放在单值数据绑定字段的前面,例如
<asp:Literal ID="Label1" runat="server" Text="No. <%#transactionCount%>"></asp:Literal>
... transactionCount不会出现。
他们是一样的乔。解析器将它们视为相同。 – 2009-06-12 12:48:53
你真的应该为此使用文字 - 正如另一张海报所说,标签用于标记表单域。在您提供的上下文中,它在语义上不正确。 – 2009-06-12 13:42:41