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();
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论