/ Published in: C#
Steps to add custom properties to web part
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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); } }
URL: http://blog.concurrency.com/sharepoint/create-a-custom-web-part-for-sharepoint-2010/