[英]Display Current Date as Lable Text using JavaScript in ASP.NET page C#
I want to display the current date as a lable text using Javascript in a asp.net Page. 我想在asp.net页面中使用Javascript将当前日期显示为标签文本。
I want to display this on page load. 我想在页面加载时显示这个。 I don't want to use any c# code
我不想使用任何c#代码
I'm trying to get in the format "Wednesday, 01 August 2012" 我想要的格式是“2012年8月1日星期三”
Can anybody help? 有人可以帮忙吗?
Simple Try jQuery : 简单试试jQuery:
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
.... ....
$(document).ready(function() {
$('#<%= txtDate.ClientID %>').val('<%=(System.DateTime.Now).ToString()%>');
});
For Label : 对于标签:
$(document).ready(function () {
$('#<%= lblDate.ClientID %>').text('<%=(System.DateTime.Now).ToString()%>');
});
.... ....
<asp:Label ID="lblDate" runat="server"></asp:Label>
If you don't want to use any C# code at all, then I suggest you go for some jquery plugin.I would go for Globalize plugin and you can display the date like this 如果您根本不想使用任何C#代码,那么我建议您使用一些jquery插件。我会选择Globalize插件,您可以显示这样的日期
$(document).ready(function() {
$('#<%= txtDate.ClientID %>').val(Globalize.format(new Date(),'D'));
});
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.