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

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!
 
P

Patrick Steele [MVP]

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.
 
T

TN Bella

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!
 
T

TN Bella

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!
 
P

Patrick Steele [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top