C# 简单日期时间程序不显示日期?
我是Asp.NET的新手 我正在尝试使用此程序显示日期:C# 简单日期时间程序不显示日期?,c#,asp.net,C#,Asp.net,我是Asp.NET的新手 我正在尝试使用此程序显示日期: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="inde.aspx.cs" Inherits="WebApplication1.inde" %> <script runat="server"> void Page_Load() { lblServerTime.Text = DateTime.Now.ToStrin
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="inde.aspx.cs" Inherits="WebApplication1.inde" %>
<script runat="server">
void Page_Load()
{
lblServerTime.Text = DateTime.Now.ToString("hh:mm:yyyy");
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>First Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
The current date and time is:
<asp:Label
id="lblServerTime"
Runat="server" />
</div>
</form>
</body>
</html>
请帮忙
当然,我们会感谢您的帮助请尝试将页面加载方法放入代码隐藏文件inde.aspx.cs请尝试将页面加载方法放入代码隐藏文件inde.aspx.cs请尝试将页面加载方法放入代码隐藏文件inde.aspx.cs请尝试将页面加载方法放入代码隐藏文件inde.aspx.cs尝试删除: CodeBehind=“inde.aspx.cs”继承=“WebApplication1.inde” 它会起作用。尝试删除: CodeBehind=“inde.aspx.cs”继承=“WebApplication1.inde” 它会起作用。尝试删除: CodeBehind=“inde.aspx.cs”继承=“WebApplication1.inde” 它会起作用。尝试删除: CodeBehind=“inde.aspx.cs”继承=“WebApplication1.inde”
它会起作用。您可以这样做:
<asp:Label ID="lblServerTime" runat="server" ><%= System.DateTime.Now %></asp:Label>
您可以执行以下操作:
<asp:Label ID="lblServerTime" runat="server" ><%= System.DateTime.Now %></asp:Label>
您可以执行以下操作:
<asp:Label ID="lblServerTime" runat="server" ><%= System.DateTime.Now %></asp:Label>
您可以执行以下操作:
<asp:Label ID="lblServerTime" runat="server" ><%= System.DateTime.Now %></asp:Label>