Surya sasidhar
Surya sasidhar

Reputation: 30303

Ajax Calendar validations

In my web application I have taken a ajax calendar in that i want to restrict the user to select future date, when user select future date should raise the error

Upvotes: 1

Views: 150

Answers (1)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

Use compare validator and set its type to Date

<asp:CompareValidator ID="cmp" ControlToValidate="TextBox1" runat="server" ErrorMessage="CompareValidator"
        Operator="LessThanEqual" Type="Date"></asp:CompareValidator>

In the codebehind set ValuetoCompare like.

 if (!Page.IsPostBack)
    {
        cmp.ValueToCompare = DateTime.Today.ToShortDateString();
    }

Upvotes: 1

Related Questions