Base class of all controls: Control

Source: Internet
Author: User
System. Web. UI namespace

The system. Web. UI namespace provides classes and interfaces for creating ASP. NET Server controls and ASP. NET web pages used as ASP. NET web application user interfaces.

This namespace contains the control class, which provides a set of common user controls for all server controls, including HTML server controls and web server controls. In addition, it includes page
Class. This class is automatically generated whenever you request a. aspx file in an ASP. NET web application. Both types can be inherited.

The control class is the base class of all controls. Common attributes, methods, and events of management controls, but do not support development of user interfaces. For Web user interface development, it is best to start from the webcontrol class, which inherits from the control class and provides the user interface functions. The control class mainly includes custom controls, user controls, and pages. The page class is used to manage. aspx pages, which is the basis of all page classes.

Attribute details

Bindingcontainer: gets the data bound control that contains the control.

Clientid: gets the Server Control identifier generated by ASP. NET.

Controls: Get controlcollection
Indicates the child control of the server control in the UI hierarchy, that is, the Child control of the server control.

Enabletheming: gets or sets a value indicating whether the topic is applied to the control.

Enableviewstate: gets or sets a value that indicates whether the server control maintains its view State to the requesting client and the view State of any child control it contains. Whether to maintain the view status

ID: gets or sets the programming identifier assigned to the server control.

Namingcontainer: gets a reference to the name container of the control on the server. This reference creates a unique namespace to distinguish the container with the same control. Id.
The server control of the property value.

Page: GetPageInstance reference.

Parent: gets a reference to the parent control of the server control in the page UI hierarchy.

Site: gets the container information, which carries the current control when presented on the design surface.

Skinid: gets or sets the appearance of the control to be applied.

Templatecontrol: gets or sets a reference to a template containing the control.

Context: obtains the httpcontext object associated with the server control for the current Web request.

Uniqueid: gets a unique identifier of a server control that is defined in a hierarchical manner.

Visible: gets or sets a value that indicates whether the server control is rendered as the UI on the page.

Detailed solution:

Methods contained in the control class are also the methods that all controls should possess, such as binding controls, searching and setting focus.

Applystylesheetskin: applies the style attributes defined in the page style sheet to the control.

Databind: overloaded. Bind the data source to the called Server Control and all its child controls.

Dispose: enables the Server Control to perform the final cleanup operation before being released from the memory.

Findcontrol: overloaded. Search for the specified server control in the current named container.

Focus: Set the input focus for the control.

GetType: Get the type of the current instance. (From Object
Inheritance .)

Hascontrols: determines whether the server control contains any child control.

Rendercontrol: overloaded. Outputs the content of the server control and stores tracking information about the control (if tracing is enabled ).

Resolveclienturl: Get the URL that the browser can use.

Resolveurl: convert a URL to a URL available on the request client.

Setrendermethoddelegate: assigns an event handler delegate to present the Server Control and its content to the parent control.

There are many other methods, please refer to msdn.

Application: traverses text controls on the page

In this example, you can find the selected check box on the page and prompt the selected content.

Stringbuilder STR = new stringbuilder ();

Foreach (control CTRL in this. Page. controls [3]. Controls)

{

If (ctr1.gettype (). Name = "checkbox") // you can specify the type of the control.

{

Checkbox cb = (checkbox) ctr1; // display the type of the Conversion Control

If (CB. Checked)

Str. append (CB. Text + "<br/>"); // connection content

}

}

Literal1.text = Str. tostring (); // display the selected content

 

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.