Get quantity of days between two dates in C #, Asp.net

Nov 14 2019 4:30 PM
This is the code of my two Textbox:
 
Textbox 1:
  1. <asp:TextBox ID="txtDate1" runat="server" ReadOnly = "true"></asp:TextBox>  
Textbox 2:
  1. <asp:TextBox ID="txtDate2" runat="server" ReadOnly = "true"></asp:TextBox>  
This is the code of my JQUERY:
  1. <script>   
  2. $(function () {   
  3. $("[id*=txtDate1]").datepicker({   
  4.   showOn: "button",   
  5.    buttonImage: "images/calendario.png",   
  6.        buttonImageOnly: true,   
  7.    buttonText: "a",   
  8.    minDate: 0,   
  9.   maxDate: 2,   
  10.       dateFormat: 'dd-mm-yy' }); });  
  11.  </script>   
  12.   
  13. <script>   
  14.      $(function () {   
  15.     $("[id*=txtDate2]").datepicker({   
  16.     showOn: "button",   
  17.     buttonImage: "images/calendario.png",   
  18.     buttonImageOnly: true,   
  19.     buttonText: "a",   
  20.     minDate: 2,   
  21.     dateFormat: 'dd-mm-yy' }); });  
  22.  </script> 
This is the code i was writing..on C# Asp.net
  1. DateTime fechaUno = Convert.ToDateTime(txtDate1.Text); 
  
  2. DateTime fechaDos = Convert.ToDateTime(txtDate2.Text); 
  
  3. TimeSpan difFechas = fechaDos.Subtract(fechaUno); 

  
I want to print the result in days in a variable

Answers (1)