Background: A Webpart that inherits System. Web. UI. WebControls. WebParts needs to modify the webpat title based on the parameters passed in by requert. The code in CreateChildControls is as follows:
1: if (string.IsNullOrEmpty(this.Page.Request["rebuildurl"]))
2: {
3: Title = this.Page.Request["rebuildurl"].Trim();
4: //base.SetPersonalizationDirty();
5: // Description = "click to view more information ";
6: }
The result shows that after the URl parameter is removed, the Title of the Webpart is restored to the original state. The value of this. Title is not saved. I found an article in the morning to mention this problem.
When does custom properties of a web part get saved?
It mentioned the need to useBase. SetPersonalizationDirty (); indicates that the personalized data has been modified!
1: if (string.IsNullOrEmpty(this.Page.Request["rebuildurl"]))
2: {
3: Title = this.Page.Request["rebuildurl"].Trim();
4: base.SetPersonalizationDirty();
5: // Description = "click to view more information ";
6: }
Note: The above method is valid on the webpart that inherits System. Web. UI. WebControls. WebParts,
Inherited fromMicrosoft. SharePoint. WebPartPages. WebPartThe webpart of hasThe SaveProperties attribute should be able to implement the same function. For more information, see
Programmatically set webpart title in web part code