Control Application -- use errorprovider

Source: Internet
Author: User

Errorprovider provides an obvious error verification prompt, which can provide a better user experience. After using it, let's take a note:

1. Drag the control.

Verify this text box. The data is limited to 0 ~ Between 65535

2. The Code is as follows:

Private void txtserverport_leave (Object sender, eventargs E)
{
Errorprovider1.clear (); // errorprovider Control
Error = false; // Boolean variable defined elsewhere, which can be ignored
String strport = txtserverport. Text. Trim ();
Try
{
Int32 intport = convert. toint32 (strport );
If (intport <0 & intport> 65535)
{
Errorprovider1.seterror(this.txt SERVERPORT, "the input number must be 0 ~ Between 65535 ");

// Seterror method. Parameter 1 indicates the space to be verified, and parameter 2 indicates the wrong string
Txtserverport. Focus ();
Txtserverport. selectall ();
Error = true;
}
}
Catch
{
Errorprovider1.seterror(this.txt SERVERPORT, "the input must be 0 ~ Number between 65535 ");
Txtserverport. Focus ();
Txtserverport. selectall ();
Error = true;
}
}

3. Regular Expressions can be used for in-depth verification. Unfortunately, I will not

Close the job.

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.