Asp. NET hands-on Tutorials (4)

Source: Internet
Author: User
Tags net object model query unique id client

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.



Related Article

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.