I am implementing a webpart, where user can change some information of the webpart itself. I store this information in webpart property.
[WebBrowsable]
[WebDisplayName("Group name")]
[Category("MyWebpart")]
[Personalizable(PersonalizationScope.User)]
public string GroupName { get; set; }
This is a code inside of my webpart, that changes GroupName property, when user selects new group:
SPWeb web = SPContext.Current.Web;
SPFile file = web.GetFile(HttpContext.Current.Request.Url.ToString());
SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.User);
System.Web.UI.WebControls.WebParts.WebPart webPart = manager.WebParts[this.ID];
((MyWebPart)webPart).GroupName = groupNameValue; //this is value I want to set
try
{
web.AllowUnsafeUpdates = true;
manager.SaveChanges(webPart);
}
finally
{
web.AllowUnsafeUpdates = false;
}
Unfortunately, user is not allowed to change this property. I tried to user RunWithElevatedPrivileges. The property is saved, but it is saved for SHAREPOINT\System, and not for current user.
Can you suggest, how to store this webpart property per user? Is there some way to store it per logged user, within RWEP? Or is there any permission level, that I could set to Members group?