Show DateTime in Form box
Hi real quick one and most likely going to look stupid after this.
I need to show the Current Date in a form text box. Also the second textbox I have needs to show the date + 3 (show the date 3 days later). For some reason I can't figure out the string to get these to post so far I got:
//Current Date when form opens
DateTime arrivaldate = DateTime.Now;
//Add 3 days to departuredate
DateTime departuredate = DateTime.Parse("DateTime.Now");
DateTime adddays = departuredate.AddDays(3);
arrivalTxb =
departureTxb =
arrivalTxb is the first text box, and departureTxb is the second text box.
The other part I have to valid to make sure the departure date doesn't go past 5 years, but thats something I think I can figure out.
Thanks in advance
EvilLinux
Junior Poster in Training
77 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
currentTextBox.Text = DateTime.Today.ToShortDateString();
threeDaysTextBox.Text = DateTime.Today.Add(new TimeSpan(3, 0, 0, 0)).ToShortDateString();
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
I feel really really stupid, because when I was playing with it again, I walked away for a bit, and then remember that I was working in the btnclick field... I.E. reason why I couldn't get the dates to come and then moved them to the correct field and bam they worked. And yeah sorry forgot the add code tags I'll fix that.
Thanks again.
EvilLinux
Junior Poster in Training
77 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0