您好親愛的所有人都希望你們都很好,做得很好,我是.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