hi u can use custom validator instead of compare validator.
<div>
expiry date: <asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
issue Date :<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:CustomValidator ID="cus" runat="server" ErrorMessage="Please enter a date lessthan exipry date" OnServerValidate="validateExpiryDate" ></asp:CustomValidator>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
the date format should be : mm/dd/yyyy or mm-dd-yyyy
ex. 06/25/2010 or 06-25-2010
the code behind is :
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void validateExpiryDate(object source, ServerValidateEventArgs args)
{
DateTime issuedate;
DateTime expirydate;
DateTime.TryParseExact(TextBox1.Text.Trim(), new string[] { "MM/dd/yyyy", "MM-dd-yyyy" }, null, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out expirydate);
DateTime.TryParseExact(TextBox2.Text.Trim(), new string[] { "MM/dd/yyyy", "MM-dd-yyyy" }, null, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out issuedate);
args.IsValid = issuedate < expirydate;
}