ASP. NET Implements user registration and verification (section 4th), asp.net User Registration

Source: Internet
Author: User

ASP. NET Implements user registration and verification (section 4th), asp.net User Registration

In the previous articles, I have already shared several articles on the implementation of verification controls. Today we will add the input data verification and verification code functions to the user logon page.
Learning Content

1. Create an ASP. NET application.
Double-click the file under the E: \ Solution1 directory and run Visual Studio 2008. On the Solution Explorer panel, right-click solution and choose add> New website from the shortcut menu to create the Chap4 site.
2. In the site Default. aspx page first add a 6 rows and 2 columns of the table, and add controls, design user registration interface: Add 6 texbox controls, respectively for the user name, password, confirm the password, QQ, E-MAIL, verification code, and then add a Button control for submission.
3. Add the control RequiredFieldValidator after the "password", enter "Enter Password" in the Text of the property panel, and add the following controls in the same way; after the password is added, add a Comparevalidator control next to it. On the Properties panel, enter the password, change ControlTovalidate to TextBOX3, change ControltoCompar to TextBOX2, and operator to Equal; add the RegularExpressionValidator control after "QQ" to verify whether the input data format matches a specific mode and edit its attributes. In the attribute panel, the format is changed to "format". In ValidationExpression, the format is changed to "China postal code" and "\ d *.
Add a RegularExpressionValidator for the E-MAIL, also change to format error in properties panel, select Internet email in ValidationExpression, change Showmessagebox to true in error message, and change showsummary to false.
4. Download The. dll file and add it to the toolbox.
On the Solution Explorer panel of Visual Studio 2008, right-click site Chap4 and choose add ASP. NET folder to Bin from the shortcut menu. In the displayed dialog box, right-click "Bin folder" and select the "add reference" command in the shortcut menu. In the displayed "add reference" dialog box, select the "Browse" tab, find WebValidates. dll file and add it to the Bin folder.
5. Drag and Drop controls to the page and register them.
6. Write the code to generate the verification code.

Public partial class _ Default: System. Web. UI. Page {protected void Page_Load (object sender, EventArgs e) {if (! IsPostBack) {SnCode. create () ;}} private bool CheckCode () {if (SnCode. checkSN (TextBox6.Text. trim () {return true;} else {SnCode. create (); return false ;}} protected void button#click (object sender, EventArgs e) {if (Page. isValid) {if (! CheckCode () {Response. Write ("<script> alert ('verification code error! ') </Scrui> ") ;}} protected void linkbutton#click (object sender, EventArgs e) {SnCode. Create ();}}

7. Run Default. aspx.
Run:

Summary
Through learning, I have mastered ASP. NET verification controls and use methods, and understand common third-party controls, master the use of Verification Code Controls, add third-party controls, you can update the verification code, the function can basically meet the requirements.

The above is all the content of the user registration and verification function compiled by Alibaba Cloud. I hope it will help you learn.

Related Article

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.