Answered by:
Peter Blum, great... but how do I set runtime date in dateTextBox ? <%# DateTime.Now%>

Question
-
User1789096816 posted
Enter Cycle Start Date:<PDP:DateTextBox ID="CycleDateInput" runat="server"></PDP:DateTextBox>
<asp:ControlParameter ControlID="CycleDateInput" Name="cycleDt" PropertyName="Text" Type="String"/>
I want to have a defualt of current date at runtime to display in the
'PDP:DateTextBox'
Don't know how... it's a string value that I'm pulling from the parameter and passing to a mainframe...
It currently shows a textbox with calender date picker and the default is a blank box... I can program on the mainframe to set to current date and my grid will display but the box is empty... I want the box by default show today's date...
Thanks...Wednesday, September 29, 2010 6:05 PM
Answers
-
User1789096816 posted
if (IsPostBack == false) { CycleDateInput.Text = DateTime.Now.ToShortDateString(); }
Thanks... a combo of what I got from you two worked out like I wanted.... the first time the page loads it will put today's date in the dateTextBox... then if the user selects a new date it refreshes the grid and keeps the users selected date to sort the records.
Hopefully I will not wear out my welcome here but expect to have 100's, 1000's or much more questions while I learn ASP.NET and C#
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, September 30, 2010 9:57 AM
All replies
-
User-211766943 posted
On page load add
if(!page.IsPostBack)
{
CycleDateInput.Text=DateTime.Now.ToString("MM-dd-yyyy");
}
Thursday, September 30, 2010 1:33 AM -
User888410735 posted
Hi,
If you want to use Date and Time then you can use
CycleDateInput.Text=Datetime.Now.ToString()
For Date alone
CycleDateInput.Text=Datetime.Now.ToString().ToShortDateTime()
Thursday, September 30, 2010 1:38 AM -
User1789096816 posted
Thursday, September 30, 2010 9:57 AM -
User1789096816 posted
if (IsPostBack == false) { CycleDateInput.Text = DateTime.Now.ToShortDateString(); }
Thanks... a combo of what I got from you two worked out like I wanted.... the first time the page loads it will put today's date in the dateTextBox... then if the user selects a new date it refreshes the grid and keeps the users selected date to sort the records.
Hopefully I will not wear out my welcome here but expect to have 100's, 1000's or much more questions while I learn ASP.NET and C#
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, September 30, 2010 9:57 AM