Home > DeveloperSection > Forums > How to use RangeValidator in asp.net
Ankit Singh

Total Post:341

Points:2389
Posted on    January-17-2016 10:34 PM

 ASP.Net ASP.Net  Validation 
Ratings:


 1 Reply(s)
 206  View(s)
Rate this:
I want to use RangeValidator in asp.net how to use please help me


aditya kumar Patel

Total Post:250

Points:1782
Posted on    January-17-2016 10:56 PM

The RangeValidator does exactly what the name implies; it makes sure that the user input is within a specified range. You can use it to validate both numbers, strings and number, we will try with a number.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RangeVailidation.aspx.cs" Inherits="Forumasp.RangeVailidation" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
     <style>
      #rngsalary {
          color:#EF0000;
      }
  </style>
</head>
 
<body>

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div>
            Salary:<br />
            <asp:TextBox runat="server" ID="txtsalary" />
            <asp:RangeValidator runat="server" ID="rngsalary" ControlToValidate="txtsalary" Type="Integer" MinimumValue="100" MaximumValue="10000" ErrorMessage="Please Enter Vailid Salary Maximum 10000 and Minimum 100!" ClientIDMode="AutoID" />
            <br />
            <br />
        </div>
    </form>
</body>
   
</html>


Modified On Jan-27-2016 05:52:37 AM

Don't want to miss updates? Please click the below button!

Follow MindStick