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.
- public override string ClientID
- {
- get
- {
- return this.ID;
- }
- }
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.
- Analysis on website construction settings of ASP. NET Website settings
- Analysis of folder permission settings in ASP. NET Website settings
- Advantages of ASP. NET
- Analysis on ASP. NET Component Design
- Implementation of ASP. NET Component Design Code