If our server control requires a more complete GUI, such as the additional property font, color, height, etc., which need to control the HTML element, should be inherited from Control's subclass WebControl to get the required basis. From the WebControl class, you need to comply with the usual agreement:
1, contain references from system.web.ui.webControl's namespace
2, can not overload the render method to provide data directly to the output stream, but to overload the renderContents method to implement
3. Under normal circumstances, WebControl's derived class is ultimately manifested as a tag in the output stream, but if you want to use other tags, you should overreload the webcontrol tagkey property or tagname property.
Experience (or MS recommendation):
1. If the control generates a non-visual element or displays to non-HTML clients, then Control should be selected as the symbol. Such as "Meta>
2, provide HTML interface from WebControl inheritance
3, expand the modified function should be derived from a memory control, but do not name the space from System.Web.ui.htmlControls, because the vs.net designer does not recognize controls from this class
In order to support the designer, you need to consider Attribute (metadata) programming.
View status
One aspect of web programming is a state management, which is to solve the status management problem based on the stateful HTTP protocol. In the ASP class Web programming technology era, this is usually solved by the following technical means:
1, session
2, cookies
3, hidden variables
4, URL
However, the above programs have their own defects, such as session, cookies may not be available in certain circumstances, hidden variables are not easy to manage, and the URL carries the length limit and the capacity is limited. . .
Comprehensive consideration, MS proposes the concept of ViewState (view) based on hidden variable regimen, and saves two ASP.NET pages in the view. How is the view work?
After processing a web request, the page framework collects the status of all controls in the page control tree and creates a view object. Every Control has a ViewState dictionary to save your own state. When you output HTML to your customers, you will serve all viewState into a string expression as an implicit variable to the client, usually we will view the string of views. The venmetal string is passed between the server with the client, and the upper request hidden variable will return to the server side to perform parallelization, and then "restore" to the server control. Essentially, it is an implicit variable, but the management function of ASP.NET is joined based on implicit variables, which is the essence of the view.
Control's enableViewState determines whether the control agrees to give its own status to automated view management.
When a control needs to be saved, no one can support the saved attribute to "simple native" data types such as INT32 Boolean. If it is a more complex attribute value type, you need to provide the programmer to provide a type converter, convert the value data into a string. If not provided, the cost of high binary serialization is employed (performed by BYTE). View data is transmitted in the delivery process to ensure that the data is not tampered with (but cannot be guaranteed, after all, Base64 is encoded).