[英]unable to set value from server-side to a Textbox in client side
我的代码是这样的
<asp:TextBox type="text" name="txtEndDate" Text="<%#library.GetDictionaryItem("ProfilePages_CVR nummer")%>" runat="server"></asp:TextBox>
一切对我来说都不错,但是我不知道为什么会抛出错误
The server tag is not well formed.
使用单引号,例如:
<asp:TextBox type="text" name="txtEndDate" Text='<%#library.GetDictionaryItem("ProfilePages_CVR nummer")%>' runat="server"></asp:TextBox>
问题是由于ASP.net括号内包含双引号
<asp:TextBox Text="<%# someMethod("someValue") %>" />
在“文本”字段中,您需要在该属性上使用单引号而不是双引号,如下所示:
<asp:TextBox type="text" name="txtEndDate"
Text='<%# library.GetDictionaryItem("ProfilePages_CVR nummer")%>'
runat="server">
</asp:TextBox>
它将起作用。
还要注意,您使用的是DataBinding表示法( <%#
),仅当您的TextBox位于DataBound控件内,或者在包含该TextBox的控件或页面上调用DataBind时,该控件才起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.