Hi nauna,
Refer the below sample.
HTML
<div>
Start Date:
<asp:TextBox ID="txtStartDate" runat="server" Text="01/Jan/2016"></asp:TextBox>
End Date:
<asp:TextBox ID="txtEndDate" runat="server" Text="31/Dec/2015"></asp:TextBox><br />
<asp:Button Text="Compare" runat="server" OnClick="Compare" />
</div>
C#
protected void Compare(object sender, EventArgs e)
{
DateTime startDate = Convert.ToDateTime(txtStartDate.Text.Trim());
DateTime endDate = Convert.ToDateTime(txtEndDate.Text.Trim());
if (startDate > endDate)
{
// Doyour stuff.
}
else
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('Start date should be greate than End date')", true);
}
}
VB.Net
Protected Sub Compare(sender As Object, e As EventArgs)
Dim startDate As DateTime = Convert.ToDateTime(txtStartDate.Text.Trim())
Dim endDate As DateTime = Convert.ToDateTime(txtEndDate.Text.Trim())
' Doyour stuff.
If startDate > endDate Then
Else
ClientScript.RegisterClientScriptBlock(Me.[GetType](), "", "alert('Start date should be greate than End date')", True)
End If
End Sub