I want to save the properties of web part somewhere in Xml/Xslt, So that if i remove a web part and then, again add it. previous properties will be retrieved automatically into the web part.

  • For a custom webpart or for all webparts (custom as well as out-of-the-box webparts)?
    – user2536
    Jul 10, 2014 at 9:18
  • Custom and out of the box webpart
    – user25707
    Jul 10, 2014 at 9:27

1 Answer 1


For custom web parts it is pretty easy. You have to override the OnPreRender event and then read or write an XML document (standard c#, no magic).

For out-of-the-box web parts it is a really difficult as there doesn't exist functionality in the SSOM which supports this universally.
To do this with out-of-the-box web parts you'd have to do 1 of 2 things:

  1. If you are on a SharePoint Enterprise, you'd have to create custom pagelayouts which has a codebehind that loops through all web parts present in the WebPartManager.
  2. Create a UserControl which gets loaded onto every page by a delegate control, which then loops through all web parts present in the Page object.

Besides the 2 points above, you'd have to make a class which not only reads all properties from an XML file, but also creates and populates all properties to a XML file. Keep in mind though that you will need to have some way to identify every individual web part. Saving properties for just a ContentEditorWebPart is not good enough as you can have multiple of those one a single page and each can have their own settings.

I am tempted to say that doing this for out-of-the-box web parts is impossible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.