ASP. NET Server Control View

Source: Internet
Author: User

ASP. NET Server Control view necessity: if our server control requires a relatively complete GUI, such as the need to control the font, color, and height of Additional HTML elements, therefore, we should inherit from the Control subclass WebControl to obtain the required basic performance. To derive from the WebControl class, follow the following conventions:

1. include references from the namespace of System. Web. UI. WebControl

2. The Render method cannot be reloaded to directly provide data to the output stream, but the RenderContents method should be reloaded for implementation.

3. Generally, the derived class of WebControl is displayed as a <span> label in the output stream, but if you want to use other labels, the tagKey attribute or TagName attribute of WebControl should be reloaded.

ASP. NET Server Control view learning experience or MS suggestions ):

1. If the Control generates non-visual elements or displays them to non-HTML clients, use Control as the identifier class for inheritance. Such as <meta> <xml> labels

2. provides HTML interface inheritance from WebControl

3. Extended modification should be derived from an existing control, but not from the System. Web. UI. HtmlControls namespace, because the designer does not recognize controls derived from this class.

To support the designer and implement the design period, you need to consider attribute (metadata) programming.

View status of ASP. NET Server Control View

One of the most important aspects of Web programming is status management, which solves the status management problem based on the stateless http protocol. In the era of asp web programming, this is usually solved by the following technical means:

1. Session

2. Cookies

3. Hide Variables

4. URL parameters

However, the above solutions all have their own shortcomings. For example, the Session should not be extended, Cookies may be unavailable in certain circumstances, and hidden variables are not easy to manage, the length and capacity of the URL parameter are limited...

Considering the concept of ViewState view based on the Hidden variable scheme, MS saves the state of the server-side controls between two ASP. NET pages through the view. How does a 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. Each Control has a ViewState dictionary to save its own State. When html is output to the customer, all viewstates are serialized as a string expression and sent to the client as an implicit variable, in general, we pass the serialized sub-string of the view between the server and the client. The implicit variable of the previous request will be uploaded back to the server for parallelization, then "Restore" to the server control. Essentially, it is an implicit variable, but added the ASP. NET management function on the basis of the implicit variable, which is the essence of the view.

The EnableViewState of Control determines whether the Control agrees to pass its status to the automatic view management.

When a control needs to be saved, no one can support the "simple native" data type such as int32 boolean. If it is a complex property value type, the programmer must provide a type converter to convert the value data to a string. If it is not provided, the expensive binary serialization function will be used one by one byte ). During the transmission process, View data is transmitted with an additional digest to ensure that the data is not tampered with, but cannot be snooped. After all, base64 encoding is almost plain text ).

The content of ASP. NET Server Control view is briefly introduced here, hoping to help you learn ASP. NET Server Control view.

  1. Introduction to ASP. NET Component Design
  2. ASP. NET Component Design-Analysis of ASP. NET Timer
  3. ASP. NET Component Design learning-creating a project library
  4. ASP. NET Server Control
  5. Introduction to ASP. NET Custom Controls

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: 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.