Total Page Preview:   000000001119

What is range validator in ASP.NET in English and Hindi

 

Range validator in ASP.NET in English

In ASP.NET, the RangeValidator control is used to ensure that the user input is within a specified range of values. This control is commonly used to validate numeric and date/time values.

Here's an example of how to use the RangeValidator control in ASP.NET:

In the example above, we have an input field for the user's age (txtAge) and a RangeValidator control (rngAge) that validates the age input. The attributes of the RangeValidator control are:
  • ControlToValidate: specifies the ID of the control to validate (in this case, txtAge).
  • ErrorMessage: specifies the error message to display if the validation fails.
  • MinimumValue: specifies the minimum allowed value for the input.
  • MaximumValue: specifies the maximum allowed value for the input.
  • Type: specifies the data type of the input (in this case, integer).
When the user submits the form, the RangeValidator control will check if the value in the txtAge field is within the specified range. If the input is valid, the form will be submitted successfully. If the input is invalid, the error message specified in the ErrorMessage attribute will be displayed to the user.
 
Note that the RangeValidator control only works on the client-side, which means that it can be bypassed by malicious users. Therefore, it's important to perform server-side validation as well to ensure the security and integrity of your application.
 
 

Range validator in ASP.NET in Hindi

RangeValidator ek ASP.NET validation control hai jo ye ensure karta hai ki user form submit karne se pehle ek specified range ke andar enter kiya gaya value hai. Is control ki madad se hum user ko validate kar sakte hai ki wo sahi range ke andar hi value enter karein. Agar user ne specified range ke bahar value enter ki hai, to RangeValidator control validation fail kar deta hai aur user ko error message show karta hai.

Yaha ek example diya gaya hai ki kaise hum RangeValidator control ko ASP.NET mai use kar sakte hai:
1-Sabse pehle, apne ASP.NET web form mai ek TextBox control ko add karein. Aap ise ya to toolbox se TextBox control ko drag and drop karke design surface pe add kar sakte hai ya phir apne .aspx file mai ye code add karke bhi kar sakte hai:
 
2-Ab, RangeValidator control ko apne web form mai add karein. Aap ise ya to toolbox se RangeValidator control ko drag and drop karke design surface pe add kar sakte hai ya phir apne .aspx file mai ye code add karke bhi kar sakte hai:
 
Is code mai, humne RangeValidator control ko add kiya hai aur uske ControlToValidate property ko TextBox1 control ke ID se set kiya hai. MinimumValue aur MaximumValue properties mai humne range ki values ko set kiya hai, jo user enter kar sakta hai. Type property mai humne data type ko set kiya hai, jisme user ka input hona chahiye (Integer, Double, Date, Currency etc.). ErrorMessage property mai humne ek error message bhi set kiya hai, jo show hoga agar user ne specified range ke bahar koi value enter ki hai.
3-Ab, apne web form mai ek Button control ko add karein. Aap ise ya to toolbox se Button control ko drag and drop karke design surface pe add kar sakte hai ya phir apne .aspx file mai ye code add karke bhi kar sakte hai:

4-Apne C# code-behind file mai, aap Button control ke Click event ko handle kar sakte hai aur check kar sakte hai ki page valid hai ya nahi. Jaise ki is example mai:

Is example mai, humne Button control ke Click event ko handle kiya hai aur check kiya hai ki page valid hai ya nahi. Page.IsValid property true return karega agar saari validation controls valid hai.
Ye ek basic example hai ki kaise hum RangeValidator control ko ASP.NET mai use kar sakte hai. Aap RangeValidator control ke appearance aur behavior ko various properties aur styles ka use karke customize kar sakte hai.
 
 
 
 
 
 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: