ASP.NET is immediately tutorial 4

xiaoxiao2021-03-06  27

Work with server controls

This part of this textbook describes some common core concepts, as well as when using server controls in the page, several often

Execution of the operation.

Disclaimer server control

ASP.NET Server Control is declared using a description flag containing the runat = "server" attribute. The following example declares

3 server controls, and custom text and styles, respectively:

C # Controls1.aspx

[Run] | [Source Code]

Operation server control

By providing a unique ID attribute for server controls, you can process each different server control in the page.

Order control. Using the ID as a reference, you can use the program to operate the object model of the server control at runtime. example

The following example demonstrates how the page developer uses the program to set the "Server"> control in the Page_Load event.

EXT attribute.

C # Controls2.aspx

[Run] | [Source Code]

Handling the behavior event of the control

ASP.NET Server controls can easily use server events, page developers can operate these events. Vocal

Binding an event to the control, the page developer can implement the operation of the control. (The attribute name of the event is tied

The set of control names, attribute values ​​indicate how the call is called, for example, the following instance code demonstrates how to pair button controls

Bind an OnClick event:

C # Controls3.aspx

[Run] | [Source Code]

Handling behavior events for multiple controls

Event processing provides a clear local method for page developers to organize logic on the page. The following example demonstration

How to bundle and process four button events in a page.

C # Controls4.aspx

[Run] | [Source Code]

Perform page steering (case 1)

Almost in all Web applications, the page turn is a very common thing. The following example demonstrates how to make

Turn with the control to another page (pass the custom query string parameter),

And how to easily access query string parameters in the target page.

C # Controls5.aspx

[Run] | [Source Code]

Perform page turn (case 2)

Not all page turning situations are implemented in the client. Client page turn and redirection

You can also be implemented using the page.navigate (url) method in the server side. Typical usage is server-side requirements

Enter the client's input and then determine where to turn.

The following example demonstrates the use of the page.navigate method to pass the parameters to the destination page, and demonstrates the page at the destination page.

How to access these parameters.

C # Controls6.aspx

[Run] | [Source Code]

Chinese Professional Network WinCheer Translation from ASP.NET. . . . to be continued. . . . . . . . .

转载请注明原文地址:https://www.9cbs.com/read-40609.html

New Post(0)