simple question about a textbox and today's date ..noob

  • Thread starter Thread starter TN Bella
  • Start date Start date
T

TN Bella

This sounds so simple...I want the textbox to automatically fill with
today's date but how is that done? To lock it so the user can't edit it,
I can use type="hidden" right? Thanks in advance for the help

<asp:textbox id="RptDate" runat="server" Width="200px">

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
tina.pardi@nav- said:
This sounds so simple...I want the textbox to automatically fill with
today's date but how is that done?

Base on your code below, just add the following in the appropriate place
in your code-behind file:

RptDate.Text = DateTime.Now.ToString()
To lock it so the user can't edit it,
I can use type="hidden" right? Thanks in advance for the help

If it's hidden, the user won't even see it (unless they do a "View
Source"). If you want it visible, but not editable, set the Enabled
property to False.
 
I am not using VS.net for behind the code, instead I am using WebMatrix.

Should I just put RptDate.Text = DateTime.Now.ToString() in the Sub for
the page load?

Thanks for responding to my question.


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Thanks it works! I had my Page load sub as private for another date
field.

Can you help me one more time and let me fix that code to display the
date in this format 11/11/00?

Thanks a bunch!



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
tina.pardi@nav- said:
Can you help me one more time and let me fix that code to display the
date in this format 11/11/00?

The "ToString()" method on DateTime is overloaded. One of the overloads
accepts a string that allows you to define formatting options.
 
Back
Top