开发者

Asp.Net(C#) Label Text inline

'>

ı need textbox text set DateTime.Now.ToLongDateString() how to开发者_JS百科 make ? must inline


Don't use the <%#%> syntax (used for binding expressions):

<%# DateTime.Now.ToLongDateString() %>

But <%=%> (same as runat="server" with Response.Write):

<%= DateTime.Now.ToLongDateString() %>

Or <%:%> if in .NET 4.0 (same as runat="server" with Response.Write and HtmlEncode):

<%: DateTime.Now.ToLongDateString() %>

See this post of the differences between the different <%%> tags.

So, this should work:

<asp:TextBox ID="TextBox1" runat="server" Text="<%= DateTime.Now.ToLongDateString() %>"></asp:TextBox>

Alternatively, in your code behind you can set this directly (in your page load event handler, for example):

TextBox1.Text = DateTime.Now.ToLongDateString();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜