When we tried to save the custom webpart property it is not retaining the values for feature usages. We explored possibility to find the solution so now I am able to save the property values.  Microsoft published good article on this.  Normally webpart persists personalization changes on webpart control without need to developer to call the SetPersonalizationDirty method. But there two cases which developer need to call this method.

The first case is when control state data is changed during the HTTP Get request to a page. By default, changes to control state data during a GET request are not persisted (for security purposes). But the SetPersonalizationDirty method provides a way to persist legitimate personalization changes to WebPart controls in this case.

The second case for calling the SetPersonalizationDirty method occurs during an HTTP POST request to a page. If a WebPart control has complex personalizable properties (such as a property that contains an ArrayList/List object), and control state data in those properties is personalized during a POST request, developers must call the SetPersonalizationDirty method to ensure that the changes are persisted.

In order to save the webpart property we need to call the this.SetPersonalizationDirty() in CreateChildControls() method as shown below.

protected override void CreateChildControls()
            Control ContrlWP = this.Page.LoadControl(@"/_layouts/userControl/testUserControl.ascx");

 If you want to share/write any other interesting points which may helps to other developer check this guideline to write the article.


Similar Topics:


setpersonalizationdirty sharepoint