tags:

views:

22

answers:

1

in my web application i have taken a ajax calender in that i want to restrict the user to select future date, when user select future date should raise the error help me thank u.

+1  A: 

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();
    }
Muhammad Akhtar
Thank u Mr.Muhammad Akhtar it is working
Surya sasidhar
hello there, now if I want to add some more like whatever the date selected I want to add 7months and 2days with that and display it in another texbox..now how to do that? thanks you
Indranil Mutsuddy