public class BEATGenericWebPart : WebPart
{
private string m_controlName;
private string m_controlTemplatesPath;
private string m_Folder;
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[WebDisplayName("Name of User Control")]
public string ControlName
{
get
{
return this.m_controlName;
}
set
{
this.m_controlName = value;
}
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[WebDisplayName("Control Templates Path")]
public string ControlTemplatesPath
{
get
{
return this.m_controlTemplatesPath;
}
set
{
this.m_controlTemplatesPath = value;
}
}
[WebDisplayName("User Controls Folder")]
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
public string Folder
{
get
{
return this.m_Folder;
}
set
{
this.m_Folder = value;
}
}
public BEATGenericWebPart()
{
this.m_controlTemplatesPath = string.Empty;
this.m_Folder = string.Empty;
this.m_controlName = string.Empty;
}
protected override void CreateChildControls()
{
try
{
string str = string.Format("{0}{1}{2}", this.m_controlTemplatesPath, this.m_Folder, this.m_controlName);
Control control = this.Page.LoadControl(str);
this.Controls.Add(control);
}
catch (Exception exception1)
{
Exception exception = exception1;
Label label = new Label();
label.Text = exception.Message;
this.Controls.Add(label);
}
}
protected override void RenderContents(HtmlTextWriter writer)
{
this.EnsureChildControls();
base.RenderContents(writer);
}
}
No comments:
Post a Comment