English 中文(简体)
截止日期。 如今直接出现在协会/协会网页上
原标题:Render DateTime.Now directly in the ASPX page
  • 时间:2012-01-16 07:18:08
  •  标签:
  • asp.net

我正试图将以下内容直接输入牛页,但没有显示日期价值。 我想从后面的法典中去做。 在这里,有一小点失踪? Pls建议。

<asp:Literal ID="ltrDate" Text= <% DateTime.Now.ToLongTimeString() %>  runat="server"></asp:Literal>

Even the use of hash in the expression <%#DateTime.Now.ToLongTimeString() %> does not work.

最佳回答

在使用数据约束性表述时,如<代码><%# 日期:Now.ToLongtimeString() %>,然后,请打电话Page.DataBind(ltrDate.Data Bind(,如果该编码是唯一有数据约束的控制权的话)从你的代码背后(例如,p_Load)。

问题回答

如果你不需要从编码背后获得许可证控制的价值,就没有必要使用。 相反,在你想要印刷日期的地方,你只能直接使用以下表述:

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

在服务器控制下,你只能将静态文字、数据约束性表述(<%# xx %>或表述制作人<%>内的财产价值内。

, 相关议题,涉及每一办法的更多细节。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签