您好亲爱的所有人都希望你们都很好,做得很好,我是.net开发新手,我正在创建一个项目,该项目将获得有关用户日常基础的信息,但问题在于我想用自动填写当前日期的日期文本框, 这是我背后的Page_Load如何使用当前日期自动填充文本框
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
namespace StackOver
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
TextBoxStartDate.Text = DateTime.Now.ToString();
if (!Page.IsPostBack)
{
LoadOptionsCardCodeTable();
LoadOptionsStageSlpNameTable();
}
}
protected void TextBoxStartDate_TextChanged(object sender, EventArgs e)
{
TextBoxStartDate.Text = DateTime.Now.ToString();
}
}
}
代码,同时也这是我的aspx.cs该文本框代码
<asp:TextBox ID="TextBoxStartDate" runat="server" ontextchanged="TextBoxStartDate_TextChanged" Width="150px" Height="16px" ></asp:TextBox>
在此先感谢它不显示错误但当前日期不显示 好心帮
上面现有的代码的结果是什么? –
空文本框表示它不填充TextBoxStartDate中的当前日期@LeiYang – Ismail
尝试 - > this.TextBoxStartDate.Text = DateTime.Now.ToString(“yyyy-MM-dd”); 可能的重复 http://stackoverflow.com/questions/21952542/how-to-set-value-from-server-side-code-to-an-asp-net-textbox-with-textmode-date – Novice