ASP.Net – How to set value of date textbox via server side code

If you are using textbox with TextMode=”Date”, you need to format the date string before setting value via server side code.

Use ToString(“yyyy-MM-dd”) to format the date value before assigning it to the text box.

txtEOIStart.Text = DateTime.Now.ToString("yyyy-MM-dd");
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s