In this article we will introduce with RangeValidator control in ASP.NET using C#.
RangeValidator Example in ASP.NET using C#
RangeValidator in ASP.NET is used to check the value which is in specified
range or not. If the value is not in specified range then the error message will
be displayed. You can set the ErrorMessage property which you want to display
for Range validator. The another property is ControlToValidate in which you can
set the attached control instance. It has a type property for the data. There
are the following value of type property.
1. String
2. Integer
3. Double
4. Date
5. Currency
In this example we use Integer property. The MinimumValue is 30 and the
MaximumValue is 60.
RangeValidator.aspx (Design Page):
RangeValidator.aspx (source code):
<%@ Page Title="" Language="C#" MasterPageFile="~/RoseindiaMaster.master" AutoEventWireup="true" CodeFile="RangeValidator.aspx.cs" Inherits="RangeValidator" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <div> <h2 style="color: Green"> RangeValidator in ASP.NET 4 , C#</h2> <strong>Age:</strong> <br /> <asp:TextBox ID="ageTextBox" runat="server" Font-Names="Verdana" /> <asp:Button ID="submitButton" runat="server" Text="Submit" Width="76px" /> <br /> <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Enter age between 30 and 60" ControlToValidate="ageTextBox" ForeColor="Red" MaximumValue="60" MinimumValue="30" Type="Integer"></asp:RangeValidator> </div> </asp:Content>
[ 0 ] Comments