public class UserControlWrapPart : WebPart
{
private string _ControlPath;
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable]
[WebDisplayName("控件路径")]
public string ControlPath
{
get { return _ControlPath; }
set { _ControlPath = value; }
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (String.IsNullOrEmpty(_ControlPath)) return;
try
{
Control ctl = Page.LoadControl(_ControlPath);
if (ctl != null)
this.Controls.Add(ctl);
}
catch (Exception ex)
{
this.Controls.Add(new LiteralControl( ex.Message ));