开发者

Ajax Calendar validations

开发者 https://www.devze.com 2022-12-09 16:52 出处:网络
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开发者_JAVA技巧 raise the errorUse compare validator an

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开发者_JAVA技巧 raise the error


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();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号