Return to Snippet

Revision: 45144
at April 26, 2011 03:02 by nickaranz


Initial Code
// MyWebPart.cs
[WebBrowsable(true),
Category("Miscellaneous"),
Personalizable(PersonalizationScope.Shared),
WebDisplayName("Enter some text")]
public string CustomTextProp { get; set; }//textbox
// options: public bool CustomCheckboxProp { get; set; }
// public ddlEnum ddlProp { get; set; } //this is required: public enum ddlEnum { option1, option2, option3 }//dropdown 

//MyWebPartUserControl.ascx.cs 
public MyWebPart WebPart { get; set; }

//MyWebPart.cs
protected override void CreateChildControls()
{
   MyWebPartUserControl control = Page.LoadControl(_ascxPath) as MyWebPartUserControl;
   if (control != null)
      control.WebPart = this;
      Controls.Add(control);
   }
}

Initial URL
http://blog.concurrency.com/sharepoint/create-a-custom-web-part-for-sharepoint-2010/

Initial Description
Steps to add custom properties to web part

Initial Title
Creating Custom Web Part Properties

Initial Tags
Development, sharepoint

Initial Language
C#