asp.net-Validating server controls

Source: Internet
Author: User

asp.net-Validating server controls
Verify that the server control is used to authenticate user input. If user input does not pass validation, it displays an error message to the consumer.

Each validation control performs a specific type of validation, such as confirming a value for a particular value or a range.

By default, when a Web page is validated, a button, ImageButton, or LinkButton control is clicked. You can prevent validation when a button, press control to set the CausesValidation property to False.

Syntax to create a validation server control is:

<asp:control_name id= "some_id" runat= "Server"/>
 
   
   

In the following example, we declare a TextBox control, a button control, and a RangeValidator control.

 

aspx file. If validation fails, the value of text "must be from 1 to 100!" "will appear in the RangeValidator control:

 

<form runat=" Server "> <p>enter a number from 1 to: <asp : TextBox id= "Tbox1" runat= "server"/> <br/><br/> <asp:button text= "Submit" runat= "Server"/> </ P

 <p> <asp:rangevalidator controltovalidate= "Tbox1" minimumvalue= "1" maximumvalue= "type=" Integer "text=" The value must is from 1 to www.111cn.net! runat= "Server"/> </p> 
 </form> Reprint Please specify www.111cn.net 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.