using
System.Runtime.InteropServices;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
Microsoft.SharePoint;
using
Microsoft.SharePoint.WebControls;
namespace
SimpleWebPart.VisualWebPart1
{
public
class
VisualWebPart1 : WebPart
{
protected
const
string
_ascxPath = @”~/_CONTROLTEMPLATES/SimpleWebPart/VisualWebPart1/CustomUserControl.ascx”;
public
VisualWebPart1()
{
}
protected
override
void
CreateChildControls()
{
try
{
Control control =
this
.Page.LoadControl(_ascxPath);
Controls.Add(control);
}
finally
{
base
.CreateChildControls();
}
}
protected
override
void
Render(HtmlTextWriter writer)
{
base
.Render(writer);
}
}
}
参考资料
Deploy User Control with webpart SharePoint 2010