Function: You can replace a asp.net control with a custom control
tagmapping element of pages (asp.net setup schema)
Defines a collection of tag types that are remap at compile time to other tag types.
This element is a new element in the. NET Framework version 2.0.
Copy Code 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:
Copy 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:
Copy Code code as follows:
<form name= "Form1" method= "post" action= "default.aspx" Id= "Form1" >
<div>
<input type= "hidden" name= "__viewstate" id= "__viewstate"/ Wepdwullte1odyxmzexnjlkzirgta8ogwnrnqd7v9zkx3zxclan "/>
</div>
<div>
<span id= "LB1" >lb</span>
</div>
</form>
Join in the Pages node of the configuration file
Copy Code code as follows:
<tagMapping>
<add tagtype= "System.Web.UI.WebControls.Label" mappedtagtype= "CJQ". Web.mylabel "/>
</tagMapping>
Where the code for the custom control is
Copy Code code as follows:
Namespace CJQ. Web
{
public class MyLabel:System.Web.UI.WebControls.Label
{
protected override void RenderContents (System.Web.UI.HtmlTextWriter writer)
{
Writer. Write ("Receive:");
Base. RenderContents (writer);
}
}
}
Its generated HTML is as follows:
Copy Code code as follows:
<form name= "Form1" method= "post" action= "default.aspx" Id= "Form1" > br><div>
<input type= "hidden name=" __viewstate "id=" __viewstate "value="/ Wepdwullte1odyxmzexnjlkzirgta8ogwnrnqd7v9zkx3zxclan "/>
</div>
<div>
<span id=" L B1 "> Receive:lb</span>
</div>
</form>