Creating Custom Properties in SharePoint Web Part A web part by default has some properties like Title, Height, Width etc‌ The values for these properties can be either set through code or by using Edit Web Part option. The properties are normally displayed in a Property Pane on the right hand side, when Edit Web Part is clicked. Also these properties are grouped into sections like Appearance, Layout and Advanced. There will be situations where we have to create a Custom Property whose value can be given by end user. The values of such Custom Properties could be used in some process during the execution of the Web Part. This can be achieved by adding a new property (member variable) in the Web Part class. This new member variable will be declared as public and Get and Set options will be used to handle the value of this property. The Web browsable attribute is set as TRUE so as to make this property visible and editable from the Edit Web Part in site. We can also mention the WebDisplayName and WebDescription attributes with Display Name and Description for the new custom property. The personalizable attribute can be set as Shared or User based on how we want it to be persisted in SharePoint. The Render() method is overridden and the new property is added using Write() method. This will render the new property in the Property Pane of Web Part. On deploying the Web Part after making the modifications mentioned here, the Property Pane of Web Part will be displaying the new Custom Property as editable for the end user.
Visit IVESIA’S WEBSITE Follow us at LINKEDIN and TWITTER