Gets or sets whether a Web Part's properties have changed and should be persisted at the end of page rendering.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
The SaveProperties property is initially set to false at the beginning of page rendering. This property is useful only during page rendering. For example, this property has no effect when a Web Part is accessed through the object model.
The SaveProperties property can be used for Web Parts when their properties have changed after being rendered in a Web Part Page. After a property has been changed, a WebPart class can set the SaveProperties property to true to specify that any changed properties will be saved. The value of the SaveProperties property will be read by the Web Part infrastructure after the System.Web.UI.Control.UnLoad event of the Web Part has occurred, at which point all property values will be queried and stored in the SharePoint database. If this property is not set, properties will revert to their original values the next time the Web Part is instantiated.
The value of the SaveProperties property is ignored unless a Web Part is actively being rendered. For example, instantiating a new Web Part, changing a property value, and then setting SaveProperties to true will have no effect. The SaveProperties property should be used by a Web Part that needs to save a property that has changed after being rendered. If a property is being set externally, it is the responsibility of the external agent to either save the Web Part explicitly, or during a render cycle to set the SaveProperties property on behalf of the Web Part.
If the SaveProperties property is set on a static Web Part (a Web Part that is not located in a zone), or for a Web Part where the user does not have sufficient permissions to save changes (such as for an anonymous user), then an exception is thrown when an attempt is made to save that Web Part. A Web Part should check the Permissions property before displaying a user interface for saving property values and setting SaveProperties to true.
To view a code sample that provides an example of how to use the SaveProperties property, see WebPart.