Date Range Validation in AJAX CalendarExtender Control using ASP.Net Range Validator
 
Published Date: Sep 17, 2011
Views: 2449
 

Abstract: Here Mudassar Ahmed Khan has explained how to implement Range Validation in ASP.Net AJAX Control Toolkit CalendarExtender Control using ASP.Net Range Validator

Comments:  1

 

In this article I will explain how to implement Range Validation in ASP.Net AJAX Control Toolkit CalendarExtender Control.
HTML Markup
<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
   
    <asp:TextBox ID="txtDate" runat="server" ReadOnly = "true"></asp:TextBox>
    <br />
    <asp:RangeValidator runat="server" ID="RangeValidator1" Type="Date" ControlToValidate="txtDate" MaximumValue='09/20/2011' MinimumValue="09/01/2011"
    ErrorMessage="Date should be between 09/01/2011 and 09/20/2011" Display="Dynamic" />
   
    <cc1:CalendarExtender ID = "Calender1" runat = "server" TargetControlID = "txtDate"></cc1:CalendarExtender>
    <br />
    <asp:Button ID="Button1" runat="server" Text="Submit" />
</form>
 
 
Above you will notice that I have an ASP.Net TextBox Control txtDate for which I have specified AJAX Control Toolkit CalendarExtender Control Calender1.
Also I have specified ASP.Net RangeValidator Control RangeValidator1 for the TextBox txtDate. This range validator will throw error when the selected date does not fit in the specified range.
In order to make the Range Validator work for the Dates. You need to specify the following paramaters
Type – Specifies that the range validations are for Dates.
MinimumValue – Specifies the minimum value of the range.
MaximumValue - Specifies the minimum value of the range.
 
Screenshot
Implement Range Validation in AJAX Control Toolkit CalendarExtender Control.
 








Related Articles



Comments



Add comments

You can add your comment about this article using the form below. Make sure you provide a valid email address
else you won't be notified when the author replies to your comment

Please note that all comments are moderated and will be deleted if they are
  • Not relavant to the article
  • Spam
  • Advertising campaigns or links to other sites
  • Abusive content.
Please do not post code, scripts or snippets.

Name*: Required
Email*: Required
Comment*: Required
Security code*: CaptchaInvalid Security Code
  Submit