开发者

Asp.Net(C#) Label Text inline

开发者 https://www.devze.com 2022-12-29 06:19 出处:网络
\'> ı need textbox text set DateTime.Now.ToLongDateString() how to开发者_JS百科 make ? must inlineDon\'t use the <%#%> syntax (used for binding expressions):

'>

ı 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

精彩评论

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