You have created a web part with custom properties and you want the property data to be persisted along with the other web part personalization data so the next time the user revisits the page, his property settings are present.
Decorate the properties in your web part that you want persisted with the Personalizable attribute:
The web part infrastructure automatically handles persisting the personalization performed by the user when he adds web parts to pages. Which web parts the user selected and their location on the page is automatically stored and retrieved when the user revisits your site. You do not have to write any code to make this happen.
Adding custom property data to the persisted data is straightforward and requires only a small modification to your code. You will need to add the Personalizable attribute to each of the properties you want persisted. No other modifications are required.
To demonstrate this technique, we added the Personalizable attribute to the BookCategory property of the book category web part described in Recipe 11.4, as shown below. With this addition, the book category the user last selected is preselected for her on subsequent requests for the page.
Storing custom property data for your web parts is a great way to enhance the user experience for your application.