Sponsored Ad

Thursday, June 24, 2010

Number Range Validator/Check in ASP.NET | RangeValidator

ASP.NET RangeValidator is very helpful to validate integer and double values range. You need not to write a javaScript code to check for number range niether write a C# code to validate at server side afterpost back.

So using this validation control you can avoid round trip to server.

 

Number Range Validator/Check in ASP.NET | RangeValidator

Number Range Validator/Check in ASP.NET | RangeValidator

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<body>
    <form id="Form1" runat="server">
        <h4>
            Check for Number Range</h4>
        <br />
        Enter a Number:
        <asp:TextBox ID="txtNumber" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Button1" Text="Validate" runat="server" />
        <br />
        <br />
        <asp:RangeValidator ID="IntRangeValidator1" ControlToValidate="txtNumber" Type="Integer"
            MaximumValue="1000" MinimumValue="100" SetFocusOnError="true" Text="The Number entered is not in given range, please enter a number between 100 to 1000."
            runat="server" />
    </form>
</body>
</html>

3 comments:

  1. Thanks for the good information...very good blog site.

    ReplyDelete
  2. i have a page which consists of label phone number and its text box. i put a required field validator and range validator to that but after submitting my submit button it wont transfer to next page if i remove range validator its working. wil u please suggest me as possible as early

    ReplyDelete
  3. you must be specifying some wrong values in range validator. For range you can use maxlength property of textbox or write a custome code to check phone number values. let me know if you face any problem.

    ReplyDelete

Sponsored Ad

Development Updates