Web部件个性化 [英] Web Part Personalization

查看:119
本文介绍了Web部件个性化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难将OOB Web部件属性保留在个人视图中。以下代码将页面切换为个人视图。我需要通过更改其区域索引来移动特定区域内的Web部件。运行此代码时,web
部分将移动,但是一旦页面刷新,更改将恢复为之前的状态。这种变化显然不会持久化数据库。仅供参考在SharePoint 2013中运行:


  WebPartManager mgr = WebPartManager.GetCurrentWebPartManager(this.Page);
$


            if(mgr.Personalization.Scope == PersonalizationScope.Shared)

                mgr.Personalization.ToggleScope();




            foreach(mgr.WebParts中的System.Web.UI.WebControls.WebParts.WebPart webPart)

            {

                if(webPart.Title ==" VisualWebPart1")

                {

$
                    mgr.BeginWebPartEditing(webPart);



                    if(webPart.ZoneIndex> 0)

                    {

                        mgr.MoveWebPart(webPart,webPart.Zone,0);

                    }¥b $ b                   否则

                    {

                        mgr.MoveWebPart(webPart,webPart.Zone,1);

                    }


                    mgr.EndWebPartEditing();



$
                   休息;

                }¥b $ b            }



任何建议都将不胜感激!




解决方案

请查看下面的链接


https://social.msdn.microsoft。 COM /论坛/办公室/ EN-US / a493edc6-f5ec-4c1e-914A-1d1c73076593 /如何对变化的阶的最web部件上,与SharePoint 2010页,通编程?论坛= sharepointdevelopmentprevious


I am having difficulty getting OOB web part properties to persist in personal views. The following code toggles the page into personal view. I am needing to move web parts within a particular zone by changing its zone index. When this code is run, the web part will move, however once the page is refreshed the change reverts back to what it was before. The change is obviously not persisting the database. FYI this is being run in SharePoint 2013:

 WebPartManager mgr = WebPartManager.GetCurrentWebPartManager(this.Page);

            if (mgr.Personalization.Scope == PersonalizationScope.Shared)
                mgr.Personalization.ToggleScope();


            foreach (System.Web.UI.WebControls.WebParts.WebPart webPart in mgr.WebParts)
            {
                if (webPart.Title == "VisualWebPart1")
                {

                    mgr.BeginWebPartEditing(webPart);

                    if (webPart.ZoneIndex > 0)
                    {
                        mgr.MoveWebPart(webPart, webPart.Zone, 0);
                    }
                    else
                    {
                        mgr.MoveWebPart(webPart, webPart.Zone, 1);
                    }

                    mgr.EndWebPartEditing();


                    break;
                }
            }

Any advice would be appreciated!


解决方案

Can you please check the link below

https://social.msdn.microsoft.com/Forums/office/en-US/a493edc6-f5ec-4c1e-914a-1d1c73076593/how-to-change-the-order-of-the-webpart-on-sharepoint-2010-page-through-programatically?forum=sharepointdevelopmentprevious


这篇关于Web部件个性化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆