Processing server control event
Each ASP.NET server control has the characteristics of an object model, including properties, methods, and events. ASP.NET development
You can use this object model to dynamically modify the page and interact with the page.
The following example demonstrates how the ASP.NET page developer will pass the ON to the control.
Click events to manipulate the TEXT property of the control.
C # Intro6.aspx
[Run] | [[Source Code]
This simple example is functionally equal to the "INTRO3" example of the previously described. However, you can find a server based on the server.
How simple and clear this version of the control!
Use custom server-side controls
ASP.NET provides 45 built-in server controls for use (see Web Forms Control Reference). except
Developers can also use the controls provided by third parties using the built-in ASP.NET controls.
The following example shows a simple calendar control (Calenda). This control uses DAR Runat = in the page.
Server> Tags to declare. Please note that using tagprefix registration at the top of the page
"ACME", using NameSpace to explain the namespace of the control. ASP.NET page analyzer will be used at runtime
This namespaces are loaded with examples of Calendar.
C # Intro7.aspx
C # Intro7.aspx
[Run] | [Source Code]
In this example, the calendar control is designed to perform "Advanced Run" in Internet Explorer 5.5 or later.
In other browsers, perform "low-level run". This can be achieved in the built-in server control provided by ASP.NET.
Monitoring to the browser version. For IE5.5 or above, he generates DHTML output. DHTML output does not require server
Reciprocation with the client's loop. For other versions of browsers, this control generates a standard HTML3.2 document. Interact
At the time, the loop reciprocation of the client and the server is required.
Important: When the page designer is writing code, it is not necessary to consider the browser when accessing the page.
Run "or" low-level run ".calendar controls have encapsulated the ability to process different browser requests.
List, data, and data binding
ASP.NET built into a table of data tables and lists, which can provide custom user interface drivers to achieve logarithm
According to the request of the library or other data source. For example, the following example demonstrates controls
How to use the SQL database query language to implement data binding to the BOOK information collection.
C # intro8.aspx
[Run] | [Source Code]
DataGrid control uses a traditional table interface to provide a simple and fast
Speed display data results. In addition, ASP.NET developers can also use R> DataList controls and customization
ItemTemplate template to customize data display mode. Please see the example below
C # INTRO9.ASPX
[Run] | [Source Code]
Notice that the control allows the end user's accurate control list of each item.
Structure and appearance display (using the itemtemplate template attribute). This control simultaneously automatically handles the content between two columns
Row (the user can control the number of columns through its REPEATCOLUMNS attribute)
The following example provides a look that a control is alternately displayed.
C # INTRO10.ASPX
[Run] | [Source Code]
Note that the controls, data models, and page users here are the same as the previous example. Differences are, this example is in the code
Dedicated to other templates.
Form verification control
ASP.NET Web Forms Page Framework provides a server verification control, which is easy to use, used to check
Check the client's incorrect input error and (if necessary) can display the prompt information to the user.
Add server authentication controls in the page just like using other server controls. Different verification conditions have different verification controls, such as input range checks or mode matching, and more. Use the RequiredFieldValidator to verify controls
To ensure that the user does not skip a field that should enter the data.
The following example demonstrates how to use controls in the page
To verify the contents of the TextBox and DropDownList controls.
C # intro11.aspx
[Run] | [Source Code]
Note that the verification control also provides "Advanced Run" and "Low-level Run" support. High version browser mode on server side
And the client execution (using Java scripts and DHTML), the low board this browser mode is only verified on the server side. Two
The program mode in the case is the same.
Note that the ASP.NET page developer can check if the page.issalid property can be checked at any time to determine if the page
All verification controls are passed. This provides a simple method for business logic processing. For example,
Examples of the surface perform a database query for a specific classification, first execute the page.issalid check.
C # intro12.aspx
[Run] | [Source Code]
Web Forms code separation
ASP.NET supports two ways to create dynamic pages. The first is that the page code is in the example as the previous example.
Declare the same .aspx file. Another method ---- people are familiar with code separation, allowing page code more tidy
, Separate the program code from HTML content to become a complete separate file.
The following example demonstrates the use of code separation technology to write ASP.NET pages
C # intro13.aspx
[Run] | [Source Code]
chapter summary
1. ASP.NET provides a simple and powerful way to establish a dynamic web user interface
2. ASP.NET Web Forms page You can automatically adapt to any browser customers (you don't need script libraries or cookie support)
)
3. ASP.NET Web Forms page provides syntax compatibility with existing ASP pages
4. ASP.NET server control provides a simple method for encapsulating common functions.
5. ASP.NET provides 45 built-in server controls. Developers can also use the control provided by third parties.
6. ASP.NET server control automatically designs advanced dynamic mode and low browser HTML mode
7. ASP.NET template can easily customize the appearance of the list server control to customize the appearance of page data display.
8. ASP.NET Verification Control can be easily verified by client or server data
Www.ourasp.net ------ Wincheer ------ Write. . . .