时间:2021-07-01 10:21:17 帮助过:13人阅读
<pages>
<tagMapping>
<add
tagType=
"System.Web.UI.WebControls.WebParts.WebPartManager"
mappedTagType=
"Microsoft.Sharepoint.WebPartPartManager,
MSPS.Web.dll, Version='2.0.0.0'"
/>
</tagMapping>
</pages>
前端代码:
代码如下:
<form id="form1" runat="server">
<div>
<asp:Label ID="lb1" runat="server" Text="lb"></asp:Label>
</div>
</form>
其生成的HTML如下:
代码如下:
<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>
在配置文件的pages节点中加入
代码如下:
<tagMapping>
<add tagType="System.Web.UI.WebControls.Label" mappedTagType="CJQ.Web.MyLabel" />
</tagMapping>
其中自定义控件的代码是
代码如下:
namespace CJQ.Web
{
public class MyLabel : System.Web.UI.WebControls.Label
{
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
writer.Write("接收:");
base.RenderContents(writer);
}
}
}
其生成的HTML如下:
代码如下:
<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>