Hi sthsyed,
Check this example. Now please take its reference and correct your code.
HTML
<div>
From Date: <input id="txtFDFromDate" runat="server" class="datepicker" clientidmode="Static"
type="text" />
<br />
From Date: <input id="txtFDToDate" runat="server" class="datepicker" clientidmode="Static"
type="text" />
<br />
Difference: <asp:TextBox ID="txtDifference" runat="server" />
<br />
<asp:Button ID="btnDifference" Text="Difference" runat="server" OnClick="Difference" Style="display: none" />
<link rel="Stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/ui-darkness/jquery-ui.css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function () {
$("#txtFDFromDate").datepicker({ dateFormat: "dd/mm/yy" });
$("#txtFDToDate").datepicker({
dateFormat: "dd/mm/yy",
onSelect: function () { $('#btnDifference').trigger("click"); }
});
});
</script>
</div>
C#
protected void Difference(object sender, EventArgs e)
{
DateTime FDFromDate = DateTime.ParseExact(Request.Form["txtFDFromDate"], "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime FDToDate = DateTime.ParseExact(Request.Form["txtFDToDate"], "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
txtDifference.Text = (FDFromDate - FDToDate).TotalDays.ToString();
}
VB.Net
Protected Sub Difference(ByVal sender As Object, ByVal e As EventArgs)
Dim FDFromDate As DateTime = DateTime.ParseExact(Request.Form("txtFDFromDate"), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Dim FDToDate As DateTime = DateTime.ParseExact(Request.Form("txtFDToDate"), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
txtDifference.Text = (FDFromDate - FDToDate).TotalDays.ToString()
End Sub
Screenshot