By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,854 Members | 869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,854 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
In article <eQ**************@TK2MSFTNGP11.phx.gbl>, tina.pardi@nav-
international.com says...
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.
<asp:textbox id="RptDate" runat="server" Width="200px">


--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 18 '05 #2

P: n/a

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!
Nov 18 '05 #3

P: n/a
In article <#e**************@TK2MSFTNGP12.phx.gbl>, tina.pardi@nav-
international.com says...
Should I just put RptDate.Text = DateTime.Now.ToString() in the Sub for
the page load?


Yes.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 18 '05 #4

P: n/a
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!
Nov 18 '05 #5

P: n/a
In article <eH*************@TK2MSFTNGP09.phx.gbl>, tina.pardi@nav-
international.com says...
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.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.