Click here to Skip to main content
15,887,331 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Actually in my Web Form Three Textbox like

txtdt1(ajaxcalnder1),txtdt2(ajaxcalender2),txtnum3

if user select any date in 'txtdt1'.
'txtdt2' must be less then the 'txtdt1' and automatically the difference between days are must be displayed in 'txtnum3'
...
how to write javascript for this

and those are server side conrolls

please tell me...
Posted

1 solution

With JavaScript : calculating-the-difference-between-two-dates-in-javascript.html[^]

With C#:
private void CalculateDateDifference()
{
    TimeSpan i = new TimeSpan(0, 0, 0);
    DateTime startDate = Convert.ToDateTime(this.txtStartDate.Text.Trim(), new CultureInfo("en-us"));
    DateTime endDate = Convert.ToDateTime(this.txtEndDate.Text.Trim(), new CultureInfo("en-us"));
    i += endDate.Subtract(startDate);
    int days = i.Days;
    this.lblDays.Text = "Total Days : " + days.ToString();
}

-KR
 
Share this answer
 
Comments
Parazival 29-Sep-15 23:30pm    
thanks for ur replay and
i want the code in javascript
Krunal Rohit 30-Sep-15 0:49am    
Go for the first link.

-KR

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