Click here to Skip to main content
15,898,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,


I have a page in which their are labels and textboxes.

I want to get today's date in createdate text box plz help
Posted

on the Page_Load event handler add this:
CreatDateTextBox.Text = DateTime.Now.Date.ToShortDateString();
 
Share this answer
 
v4
Comments
Mohamed Mitwalli 23-Jun-12 5:48am    
5+
C#
TextBox1.Text =Convert.ToString(DateTime.Now);
 
Share this answer
 
C#
protected void Page_Load(object sender, EventArgs e)
{
            DateTime dNow = DateTime.Now;

            txt_date.Text = (dNow.ToString("yyyy-MM-dd"));
            txt_date.Text = (dNow.ToString("dd/MM/yyyy"));
            txt_date.Text = (dNow.ToString("dd-MM-yyyy"));

}
 
Share this answer
 
v2
in pageload event write this code

C#
txtDate.Text = System.DateTime.Now.ToString("dd-MMM-yyyy");
 
Share this answer
 
C#
protected void Page_Load(object sender, EventArgs e)
{
           Text_Date.Text = System.DateTime.Now.ToString("dd-MM-yyyy");


}
 
Share this answer
 
Use the below code for precise:

C#
Textbox1.Text = DateTime.Now.ToShortDateString();


This give exactly the date in string format
 
Share this answer
 
v2
Comments
Mohamed Mitwalli 23-Jun-12 5:48am    
It's already answer before First solution if you have different answer you can post it .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900