Adding Custom webpart properties in SharePoint Visual Webpart
1. Add Property in Webpart1.ascx.cs Page
public Webpart1 WebPart { get; set; }//Change Webpart class name in place of "Webpart1"
2.Overrite CreateChildControls method in Webpart1.cs Page
protected override void CreateChildControls()
{
Control control = Page.LoadControl(_ascxPath);
if (control != null)
{
((Webpart1UserControl)control).WebPart = this; //Change Webpart User Control Name
}
Controls.Add(control);
}
3.Add Custom Properties in Webpart1.cs page
#region Custom Properties
[Category("GMDM Properties"), //Change Custom Property Group Name
Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("URL"), //Change Property name
WebDescription("Please Enter URL")] //Change Property Description
public string strUrl
{
get;
set;
}
#endregion
1. Add Property in Webpart1.ascx.cs Page
public Webpart1 WebPart { get; set; }//Change Webpart class name in place of "Webpart1"
2.Overrite CreateChildControls method in Webpart1.cs Page
protected override void CreateChildControls()
{
Control control = Page.LoadControl(_ascxPath);
if (control != null)
{
((Webpart1UserControl)control).WebPart = this; //Change Webpart User Control Name
}
Controls.Add(control);
}
3.Add Custom Properties in Webpart1.cs page
#region Custom Properties
[Category("GMDM Properties"), //Change Custom Property Group Name
Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("URL"), //Change Property name
WebDescription("Please Enter URL")] //Change Property Description
public string strUrl
{
get;
set;
}
#endregion
No comments:
Post a Comment