我尝试过以下代码..
{
string dt;
protected void Page_Load(object sender, EventArgs e)
{
dt = DateTime.Now.ToShortDateString().ToString();
date.Text = dt;
}
protected void decr_Click(object sender, EventArgs e)
{
date.Text = Convert.ToDateTime(date.Text).AddDays(-1).ToShortDateString().ToString();
}
protected void incr_Click(object sender, EventArgs e)
{
date.Text =Convert.ToDateTime(date.Text).AddDays(1).ToShortDateString().ToString();
}
答案 0 :(得分:0)
在Page_Load
if (!Page.IsPostBack)
事件的代码
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
dt = DateTime.Now.ToShortDateString().ToString();
date.Text = dt;
}
}