其实也很简单,
1。 步骤1写好自己的用户控件,然后,把他用户控件的页面放到
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\WpLoadUc\AddUserControl.ascx下面
然后把dll放到相应的moss bin 下面 或GAC
2。写一个WebPart,很简单,代码如下:
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace WPLoadUserControl
{
[Guid("0d2c817f-71c3-4349-b813-cf8eb81f4bd5")]
public class WPLoadUserControl : System.Web.UI.WebControls.WebParts.WebPart
{
protected Control userControl;
public WPLoadUserControl()
{
this.ExportMode = WebPartExportMode.All;
}
protected override void CreateChildControls()
{
//base.CreateChildControls();
this.Controls.Clear();
string userControlPath = @"/_controltemplates/WpLoadUc/AddUserControl.ascx";
this.userControl = this.Page.LoadControl(userControlPath);
this.Controls.Add(this.userControl);
}
protected override void Render(HtmlTextWriter writer)
{
// TODO: add custom rendering code here.
writer.Write("Show AA");
this.userControl.RenderControl(writer);
}
}
}
代码是不是很简单哦,WebPart 的部署就不用我说啦。。。
3,然后修改下配置文件
<SafeControl src="~/_controltemplates/WpLoadUc/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" />
嘿嘿 指定到相应的用户控件哦。
哈哈哈 ,各位是不是很简单,,嘿嘿快去测试哦。/
。。。。。。。。。。。。。
代码不是最好的,只是供大家参考。。