我们有自定义代码,以允许用户在个人视图中删除,添加或重新排序页面上的网页。它是一个使用模板创建的发布Web部件页面。

如何对此页面进行更新,例如删除Web部件?(显然,如果我设置ignoreifalReadyExists=真正的Web部件将被添加到页面上。)到目前为止,我们一直删除并重新创建页面。这会破坏用户可能已经完成的任何Web部件个性化,并且不再可以接受,因为我们现在正在生产中。

是否有一种方法可以在删除和重新创建页面后备份和恢复用户的个人视图?

有帮助吗?

解决方案

In simple terms doing something like (important here is of course PersonalizationScope.User):

        SPLimitedWebPartManager webPartManager = SPContext.Current.Web.GetLimitedWebPartManager(this.Request.Url.ToString(), PersonalizationScope.User);
        int wpCounter = webPartManager.WebParts.Count; //get counter
        /*either start looping or for a single web part use*/        
WebPart webPart = webPartManager.WebParts[wpId];
         /*do something with the web part*/

But this has 1 important limitation - it only works for Web parts placed in Web part zone. In addition there is a method (actually part of the ASP.NET Web part infrastructure) called SavePersonalizationState via the Personalization property on each Web part, see more here (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.personalizationprovider.savepersonalizationstate(v=vs.90).aspx). I haven't really been in a situation to try myself!

The biggest challenge would be maybe to collect personalization data for all users. Maybe the fact that it uses the Provider pattern could help, by using the FindState method (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.personalizationprovider.findstate(v=vs.90).aspx) to extract all data.

许可以下: CC-BY-SA归因
scroll top