[英]ASP Text Box Mode Date Time setting Current DateTime
TextBox, Text mode set to DatetimeLocal TextBox,文本模式设置为DatetimeLocal
<!--Date-->
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<h4>Date</h4>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<asp:TextBox ID="txtDate" runat="server" TextMode="DateTimeLocal"></asp:TextBox>
</div>
</div>
Here is my page_load Handler, setting current date time in textbox 这是我的page_load处理程序,在文本框中设置当前日期时间
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["user"] != null)
{
txtDate.Text = DateTime.Now.ToString();
}
else
Response.Redirect("login.aspx");
}
}
Current datetime not showing in textbox. 当前日期时间未显示在文本框中。 .
。 .
。
您需要在分配日期之前解析日期:
txtDate.Text = DateTime.Now.ToLocalTime().ToString("yyyy-MM-ddTHH:mm");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.