[Original] extaspnet Secret Garden (2)-everything starts from scratch

Source: Internet
Author: User

This articleArticleWe will use extaspnet from the beginning to complete a simulated User Logon interface, as shown below:

Project Preparation

1. Create an ASP. NET web applicationProgramProject.

2. download the latest version of extaspnet from the open-source website, and add references to extaspnet. dll in the new project.

Create An ASPX page

1. Add a declaration on the <HTML> tag

 
<%@RegisterAssembly= "Extaspnet"Namespace= "Extaspnet"Tagprefix= "Ext"%>
 
 
2. Add the pagemanager control to the <form> label.
 
<Ext: pagemanager ID= "Pagemanager1" Runat= "Server" />

Each page using the extaspnet control must contain a pagemanager control, which is used to control global parameters at the page level. For example, to control the page style, language, form parameters, Ajax parameters, and layout parameters, a later article will specifically introduce this control.

 

3. Design the login form

Because we want to center the login form, a window control is nested outside the form, and the window control is centered (in fact, in the left-right corner, the top and bottom are at the Golden split point.

<Ext: Window ID= "Window1" Runat= "Server" Title= "Logon form" Ismodal= "False" Enableclose= "False" Windowposition= "Goldensection" Width= "350px"></Ext: Window>
 
 
 
 

This so-called golden split point is throughWindowposition= "Goldensection" is set, which is also an innovation of extaspnet (it is said that when the human eye is viewing a webpage, the above line of sight is roughly located at the Golden Point, rather than the center ).

To achieve this functionCodeIn/extaspnet/JS/x. WND. JS, The _ calculategoldenposition function is as follows:

1:Function_ Calculategoldenposition (bodysize, windowsize ){
 
2:VaRTop = (bodysize. Height-(bodysize. Height/1.618)-windowsize. Height/2;
 
3:If(Top <5 ){
 
4:Top = 5;
 
5:}
 
6:VaRLeft = (bodysize. Width-windowsize. width)/2;
 
7:If(Left <0 ){
 
8:Left = 5;
 
9:}
10:Return{Left: left, top: Top };
 
11:};
 
 
 
 

 

4.Add simpleform control in window

The final window tag in aspx is as follows:

 
1:<Ext: Window ID= "Window1" Runat= "Server" Title= "Logon form" Ismodal= "False" Enableclose= "False"
 
2:Windowposition= "Goldensection" Width= "350px">
 
3:<Items>
4:<Ext: simpleform ID= "Simpleform1" Runat= "Server" Showborder= "False" Bodypadding= "10px"
 
5:Labelwidth= "60px" Enablebackgroundcolor= "True" Showheader= "False">
 
6:<Items>
7:<Ext: textbox ID= "Tbxusername" Label= "User Name" Required= "True" Runat= "Server">
 
8:</Ext: textbox>
9:<Ext: textbox ID= "Tbxpassword" Label= "Password" Textmode= "Password" Required= "True" Runat= "Server">
 
10:</Ext: textbox>
11:<Ext: button ID= "Btnlogin" Text= "Login" Type= "Submit" Validateforms= "Simpleform1" Validatetarget= "TOP"
 
12:Runat= "Server" Onclick= "Btnlogin_click">
 
13:</Ext: button>
14:</Items>
 
15:</Ext: simpleform>
 
16:</Items>
 
17:</Ext: Window>

This example involves several controls: pagemanager, window, simpleform, Textbox, And button. Many Attributes are self-explanatory and will be detailed later.

Background code
 
1:Protected VoidBtnlogin_click (ObjectSender, eventargs E)
2:{
 
3:If(Tbxusername. Text ="Admin"& Tbxpassword. Text ="Admin")
 
4:{
 
5:Alert. showintop ("Successfully logged on! ");
 
6:}
 
7:Else
 
8:{
 
9:Alert. showintop ("The user name or password is incorrect! ", Messageboxicon. Error );
 
10:}
 
11:}

The logic here is very simple. If the user name and password are correct, the pop-up dialog box displays "Successful Logon !", Otherwise, an error message is displayed.

 

 

Summary

Although the entire example seems simple, it implements many tasks that cannot be implemented or are difficult to complete by common ASP. NET:

1. Do not use a line of JavaScript code to center the form.

2. a drag-and-drop form

3. Client verification in the user name and password input box

4. Form sending back is not a whole page sending back, But Ajax (this is also extaspnet's native Ajax, which has Ajax features by default without any configuration or special code)

5. The beautiful prompt box is generated through the C # code (and can be displayed in the current page framework or parent page framework, which is also extaspnet's specific IFRAME-based framework)

 

In the next article, we will focus on modifying web. config to configure global parameters required by extaspnet.

 

 

 

Note: "extaspnet Secret Garden" series of articles are original from sanshenshi, blog Park first launched, reprinted please indicate the source. Document Catalog official forum

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.