Declaring server controls
Asp. NET server control is declared using a description flag that contains the runat= "server" attribute. The following example declares 3 <asp:label runat= "Server" > server controls, and customizes text and styles individually:
C # controls1.aspx
Manipulating server controls
By providing a unique ID attribute to a server control, you can control each of the different server controls in the page. Using IDs as references, you can use programs to manipulate the object model of a server control at run time. For example, the following example demonstrates how a page developer can use a program in the Page_Load event to set the Text property of the <asp:label runat= "Server" > control.
Handling Behavior Events for controls
asp.net server controls make it easy to use service-side events, and page developers can manipulate these events. By declaring the binding of an event to a control, the page developer can implement the action on the control. (The property name of the event represents the bound control name, and the property value represents the method that will be invoked) For example, the following instance code demonstrates how to bind a button control to an onclick event:
Handling behavior events for multiple controls
Event handling provides a clear way for page developers to organize logic in a page. The following example shows how to bundle and handle four button events in a single page.
Perform page turn (condition 1)
In almost all Web applications, page turns are a common thing. The following example shows how to use the <asp:hyperlink runat=server> control to move to another page (passing a custom query string parameter) and how to easily access query string parameters on the target page.
Perform page turn (condition 2)
Not all page-turn situations are implemented on a client-side via a hyper-connection. The client's page redirection and redirects can also be implemented on the server side using the Page.navigate (URL) method. A typical usage is a server-side requirement to validate the input of the client and then decide where to turn.
The following example shows the use of the Page.navigate method to pass parameters to the destination page, while demonstrating how to access these parameters on the destination page.