Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox does not accept Default Date (Today) 1

Status
Not open for further replies.
Mar 14, 2002
711
US
I have 2 ASP.net pages, very similar to each other, one has a textbox with a Text="<%Date.Today()%>" in the HTML section of the code, and when you run the page on the web, it will fill in Today's date, whereas if I use the exact same code on a different asp.net page, all the textbox does is fill in <%Date.Today()%>, just as if I had typed that in...

Why would one page differ from another??
 
Should not be Text="<%Date.Today()%>"

should be <asp:TextBox id=tb1 runat=server Text='<%Date.Today()%>' />

(single quotes)
 
Hmmm, this is what I have now, and still it fills in the textbox with the text value rather than the date...maybe I am missing something else?

<asp:TextBox id="WorkDate" style="Z-INDEX: 103; LEFT: 139px; POSITION: absolute; TOP: 325px" Width="116px" runat="server" Text='<%Date.Today()%>'/></asp:TextBox>

 
Why not use code behind?:
Code:
'Use in the Page_Load Event...
WorkDate.Text = Today.ToShortDateString
 
Excellent - thanks jbenson001, that worked super...should have thought of that :- )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top