如何在非发布站点上判断页面是否处于编辑模式 [英] How to tell if page is in edit mode on a non-publishing site

查看:17
本文介绍了如何在非发布站点上判断页面是否处于编辑模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们的发布站点,我们使用 SPContext.Current.FormContext.FormMode 枚举来确定当前页面是否处于编辑模式.我已经看到这不适用于我目前正在处理的团队网站.FormMode 始终设置为无效".

For our publishing sites we use the SPContext.Current.FormContext.FormMode enum to work out if the current page is in edit mode. I've seen that this does not work for a team site I'm currently working on. The FormMode is always set to 'Invalid'.

但是,当我在示例页面上单击编辑页面"时,页面会切换到编辑模式,因此必须有其他方式知道页面处于编辑模式.那么,如何判断我是否处于工作组网站中页面的编辑模式?

However, when I click edit page on a sample page, the page does switch to edit mode so there must be some other way of knowing that a page is in edit mode. So how can I tell if I'm in edit mode for a page living in a team site?

干杯.杰斯.

推荐答案

对于我的方案,我发现我可以利用 WebPartManager 对象以确定当前页面是否处于编辑模式.

For my scenario, I've found that I can make use of the WebPartManager object to find out if the current page is in edit mode.

Dim wpm As WebPartManager = WebPartManager.GetCurrentWebPartManager(Page)

result = wpm.DisplayMode.Name.Equals("design", StringComparison.InvariantCultureIgnoreCase)

以上代码通知我当前页面是否处于编辑模式,因为 webpart 区域处于设计模式.当不在设计模式时,DisplayMode 通常是浏览".

The above code informs me whether the current page is in edit mode, since the webpart zone is in design mode. When not in design mode, the DisplayMode will usually be 'Browse'.

这篇关于如何在非发布站点上判断页面是否处于编辑模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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