Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have two ajax calender control on two textboxes as start date and end date and having a Label.Now the thing is this as user enter start date and end date on selection of date on endate textbox no of days should be soon in Label.I used onblur event of end date but it's firing before selection complete date and the error is generating as date in invalid form.

Please let me know if u people have another solution.

thanking you
mohammad Wasif
Posted
Updated 4-Mar-11 0:21am
v2

try this one


at end date_Text Changed at coding side

DateTime sDateTime = Convert.ToDateTime(startdate.Text);
DateTime eDateTime = Convert.ToDateTime(enddate.Text);
System.TimeSpan span = eDateTime - sDateTime;
int ddays = (int)span.TotalDays;
label.Text=ddays.ToString();
 
Share this answer
 
Comments
Nelek 7-Oct-13 6:27am    
Did you realize that the question over two years old is?
Why not use a Calendar control instead? That way you always have a sensible date, and the user can't make a mistake and enter it in the wrong format...
MSDN[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900