This article mainly describes the way to replace a asp.net control with a custom control, which you need to refer to in the following
Function: You can replace a asp.net control with a custom control pages tagmapping element (asp.net setup schema) defines a collection of tag types that are mapped at compile time to other The tag type. This element is a new element in the. NET Framework version 2.0. Code as follows: <pages> <tagMapping> <add tagtype= " System.Web.UI.WebControls.WebParts.WebPartManager " mappedtagtype= " microsoft.sharepoint.webpartpartmanager, MSPS. Web.dll, version= ' 2.0.0.0 ' " /> </tagMapping> </pages> front-end code: Code as follows: <form id= "Form1" runat= "Server" > <div> <asp:label id= "LB1" runat= "Server" text= "LB" ></asp:Label> </div> </form> Its generated HTML is as follows: code as follows: <form name= "Form1" method= "post" action= "default.aspx" Id= "Form1" > <div> <input type= "hidden" name= "__" VIEWSTATE "id=" __viewstate "value="/wepdwullte1odyxmzexnjlkzirgta8ogwnrnqd7v9zkx3zxclan "/> </div> <div> <span id= "LB1" >lb</span> </div> </form> in the pages node of the configuration file add The code is as follows: <tagMapping> <add tagtype= "System.Web.UI.WebControls.Label" mappedtagtype= cjq. Web.mylabel "/> </tagMapping> The code for the custom control is code as follows: namespace CJQ. web { public class mylabel:system.web.ui.webcontrols.label { protected override void Rendercont Ents (System.Web.UI.HtmlTextWriter writer) { writer. Write ("Receive:"); base. RenderContents (writer); } } } Its generated HTML follows the following: code: <form name= "Form1" method = "POST" action= "default.aspx" Id= "Form1" > <div> <input type= "hidden" name= "__viewstate" id= "_ _viewstate "value="/wepdwullte1odyxmzexnjlkzirgta8ogwnrnqd7v9zkx3zxclan "/> </div> < div> <span id= "LB1" > Receive:lb</span> </div> </form>