『笔记』Webpart加载*.ascx页面转换代码
替换 xxxx.cs 文件中的RenderWebPart()方法。代码如下:
其中 LoadControl("/bin/WebUserControlTest.ascx") 就是要加载的 *.ascx 文件名了。
protected override void RenderWebPart(HtmlTextWriter output)
{
this.EnsureChildControls();
_innerWebControl.RenderControl(output);
}
private System.Web.UI.Control _innerWebControl;
protected override void CreateChildControls()
{
_innerWebControl=this.Page.LoadControl("/bin/WebUserControlTest.ascx");
this.Controls.Add(_innerWebControl);
base.CreateChildControls ();
}
{
this.EnsureChildControls();
_innerWebControl.RenderControl(output);
}
private System.Web.UI.Control _innerWebControl;
protected override void CreateChildControls()
{
_innerWebControl=this.Page.LoadControl("/bin/WebUserControlTest.ascx");
this.Controls.Add(_innerWebControl);
base.CreateChildControls ();
}
其中 LoadControl("/bin/WebUserControlTest.ascx") 就是要加载的 *.ascx 文件名了。