Make login page with ASP.NET
Create By Wang Minggang 2002-05-16
Generally there will always be a login page in a system, at the same time, the production of the login page is the road to all system developers!
First, let's take a look at the main features in this login page:
1. Verify that the data entered by the user is complete!
2. Verify that the data entered by the user meets the requirements, such as whether the name is 4-10 characters, whether the password is 4-8 characters.
3. At the same time, in this page, the Pagelet (web fitting) of ASP.NET is used.
Now, let's take a look at how the specifically makes this page.
the first. How to verify that the data entered by the user is complete, people who have made ASPs understand. Different is that information is displayed in ASP.NET is label.text = ..., indicating that this Label will display.
IF userid = "" and password = "" "THEN
Label2.text & = "Please enter your name and password!"
EXIT SUB
Else
IF userid = "" "
Label2.text & = "Please enter your name!"
EXIT SUB
Else
if Password = "" "
Label2.text & = "Please enter your password!"
EXIT SUB
second. Verify that the data entered by the user meets the requirements
Here, use ASP.NET RegularExpressionValidator control components, regular expression is a powerful string definition rule that let us look directly: as shown below, the [Name] column in the form must enter 4-10 characters, The [Password] column must enter 4-8 characters.
Name :: [A-ZA-Z0-9] {4,10}
Password: [A-ZA-Z0-9] {4,8}
For the above-defined Regular Expression string, as follows:
[]: Used to define acceptable characters, A-Z represents lowercase A-Z is acceptable characters, A-Z is also, and digital 0-9 is acceptable.
{}: Used to define the number of characters that must be entered, {4, 10} indicates at least 4 characters, with up to 10 characters.
Let us now take a look at the arrangement method of Regular Expression on the webpage:
ValidationExpression = "[A-ZA-Z0-9] {4, 10}"> (Please enter 4-10 characters) asp: regularExpressionValidator> td> TR> ValidationExpression = "[A-ZA-Z0-9] {4,8}"> (Please enter 4-8 characters) asp: regularExpressionValidator> General Regular Expression It is behind the form element to be controlled. In the web page, e-mail, phone, address is a common input bar. For details, we can give one or three by the above example. second. At the same time, in this page, it also uses the ASP.NET Pagelet (web fitting). PageLet (web accessory)? What is the popular point of Pagelet (web accessories), if the popular point, I want to be the small pendant on the Christmas tree. Look at the top section of the page: My first header 2002-4-30 14:49:32 And below: Learn Asp.net to find me This is two Pagelet! Let's take a look at how it is made: On this login page, the two lines of code are used, indicating that you can log in to the controls that can be referenced by using the Pagelet, log in to Header.ascx, Footer.ascx's tags as follows <% @ register tagprefix = "wangmg" tagname = "header" src = "Header.ascx"%> <% @ register tagprefix = "wangmg" tagname = "footer" src = "footer.ascx"%> Several properties are set as follows: SRC: Pagelet Source File. TAGNAME: Pagelet Category Name, this example is Header and Footer. TagPRefix: Pagelet Category The front guide name, this example is: wangmg. After the above settings, Header.ascx, footer.ascx will become the pagelet that can be referenced by the web, and the Pagelet's category name is: "wangmg: table", after the category name is defined, the tag of the control element is arranged in the web page. : In addition to the use of <% @ register%> Logging in Pagelet, the method using the Pagelet is identical to the method using the ASP.NetWeb control component, and it can be set to the Pagelet setting ID, and the RUNAT attribute is set to "Server". Let's take a look at Header.ascx, Footer.ascx HEADER.ASCX:
Password: TD>