Development of ASP. NET controls-analysis of methods for modifying server controls

Source: Internet
Author: User

How does one modify ASP. NET Server controls in ASP. NET control development? The following describes how to modify the ID and Name of a server control:

The generated ID and Name can be removed through several methods.

ASP. NET control development-Methods for modifying the ID and Name of an ASP. NET Server Control 1.

Use HTML

This method is good. The name attribute is not required for html tags, such as htmlLink. The name attribute is required for form submission.

The first part overrides the ClientID attribute of the Control class.

This attribute is read-only.

 
 
  1. public override string ClientID  
  2. {  
  3.     get 
  4.     {  
  5.         return this.ID;  
  6.     }  

In this way, the ID returned by the control will not be very complex.

ASP. NET control development-method 2 for modifying the ID and Name of the ASP. NET Server Control.

Form

You can override the Name attribute of the HtmlInputControl class.

The above two points can be implemented through System. Web. UI. Adapters. ControlAdapter.

ASP. NET control development-Methods for modifying the ID and Name of an ASP. NET Server Control 3.

Web Server Control

The id and name are output in the AddAttributesToRender method, and the method will be called in the RenderBeginTag method.
Suppose we want to use System. web. UI. webControls. adapters. if WebControlAdapter is used to implement the RenderBeginTag method, the TagName of the control cannot be obtained. If you recreate the control, you can expose the TagName attribute.

RenderEndTag cannot be output. Do you want to rewrite RenderEndTag ?, Then, you can determine the type of the control one by one. Or in this case, the workload will be relatively large. It is a pity that you cannot get the TagName.

The other method is to override the AddAttributesToRender method. However, some features will be sacrificed.

We recommend that you use HTML controls with System. Web. UI. Adapters. ControlAdapter to discard the nasty nested code. You can use them with the MVC framework.

The methods for modifying ASP. NET Server controls in ASP. NET control development are introduced here. I hope this will help you.

  1. Analysis on website construction settings of ASP. NET Website settings
  2. Analysis of folder permission settings in ASP. NET Website settings
  3. Advantages of ASP. NET
  4. Analysis on ASP. NET Component Design
  5. Implementation of ASP. NET Component Design Code

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.