Function: You can replace an asp.net control with a custom control.
TagMapping element of pages (ASP. NET setting Architecture)
Defines a set of tag types that are remapped to other tag types during compilation.
This element is a new element in. NET Framework 2.0.
Copy codeThe Code is as follows:
<Pages>
<TagMapping>
<Add
TagType =
"System. Web. UI. WebControls. WebParts. WebPartManager"
MappedTagType =
"Microsoft. Sharepoint. webpartmanager,
MSPS. Web. dll, Version = '2. 0.0.0 '"
/>
</TagMapping>
</Pages>
Front-end code:
Copy codeThe Code is as follows:
<Form id = "form1" runat = "server">
<Div>
<Asp: Label ID = "lb1" runat = "server" Text = "lb"> </asp: Label>
</Div>
</Form>
The generated HTML is as follows:
Copy codeThe Code is 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>
Add the following content to the pages node of the configuration file:
Copy codeThe Code is as follows:
<TagMapping>
<Add tagType = "System. Web. UI. WebControls. Label" mappedTagType = "CJQ. Web. MyLabel"/>
</TagMapping>
The custom control code is
Copy codeThe Code is 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 );
}
}
}
The generated HTML is as follows:
Copy codeThe Code is 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"> receive: lb </span>
</Div>
</Form>