Question22
You create a Feature.You need to remove the link to the Site Content Type page from the Site Settings page by using the Feature.Which element should you use in the Feature?A. ContentTypeB. ContentTypeBindingC. HideCustomActionD. Module解析:
本题就是要移除Site Setting页面中的Galleries栏下的Site Content types设置链接。如下图:
选项C. HideCustomAction就是本题的答案,针对本题的使用代码示例如下:
D. Module,属于模块格式。所谓模块部分就是按照类似于在 Onet.xml 文件中定义模块的方式在元素指令清单中定义模块,以便指定用于设置 SharePoint 网站的文件。可以将零个或多个 File 元素作为 Module 元素的子级。而Module元素用地指定在元素指令清单中设置 SharePoint 网站的文件。
所以本题目正确选项应该是C参考:
Question23
You have a SharePoint site. The current master page of the site is v4.master.You create a custom master page named MyMasterPage.master.You deploy the master page to /_catalogs/masterpage/.You need to apply the custom master page to only the content pages of the site.What should you do?A. Rename the custom master page as v4.master and overwrite /_catalogs/masterpage/v4.master.B. Rename the custom master page as v4.master and overwrite \14\TEMPLATE\GLOBAL\v4.master.C. Set the MasterUrl property and CustomMasterUrl property of the site to /_catalogs/masterpage/MyMasterPage.master.D. In the @Page directive of each page layout, set the MasterPageFile attribute to /_catalogs/masterpage/MyMasterPage.master.解析:
本题的意图就是把某个Site的Content Pages(内容页)的母板页设置为用户自定义的母板页。 下面我们逐一讲解:一、首先是了解Sharepoint的页面类型: Microsoft SharePoint Foundation 中主要有两种类型的页面,分别是应用程序页(Application Page) 和网站页(Site Page)。 应用程序页(Application Page) 和网站页(Site Page)都从同一母版页继承其布局。 应用程序页(Application Page)与传统的 Microsoft ASP.NET 3.5 网页最为相似。但是,应用程序页面并非直接派生自System.Web.UI.Page,而是派生自 LayoutsPageBase 或 UnsecuredLayoutsPageBase。 网站页(Site Page)是由最终用户创建、编辑和自定义的页面,是可以由用户个性化定制与修改的页面。网站页是通过存储在前端 Web 服务器(Front-End Web Server)的文件系统上的模板页面设置的。在设置网站时,SharePoint Foundation 会创建指向文件系统上的页面模板实例的指针,这个指针存放在使用了此网站页的Website的Content Database中。这样,SharePoint Foundation 就可以避免重复创建每次创建网站时都要设置的页面的副本。而本题所说的Content Pages(内容页)就是我们上面所说的Site Pages.二、了解v4.master母板页SharePoint2010 Foundation 使用 v4.master 作为其主要母版页。所有内容页(Content Pages)和应用程序页(Application pages)都使用 v4.master。安装该产品后,母版页位于 %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\GLOBAL 目录中(即:本题的选项B 所示路径: \14\TEMPLATE\GLOBAL\v4.master )。如果针对特定 SharePoint Foundation 网站编辑该母版页,则编辑后的母版页文件副本将存储在内容数据库中(即:本题的选项A: /_catalogs/masterpage/ 此路径就是一个virtual path, 存在于内容数据库[Content Database]中, 而不是存在于文件系统中。也即, 修改后的V4.master就存放在Masterpage Gallery中,你可以使用SharePoint Designer来把修改后的V4.master存放到这里。) 所以选项A与选项B对于本题并无实质的区别,它们之间的区别就是存放位置的不同,产生的方式不同。它们的共同点就是都使用了V4.master,而按照上面的描述,V4.master是对”所有”的内容和应用程序页都适用。但本题要求的是只针对某个Site内的Content Page(内容页)。所以使用和修改V4.master显然不符合本题的要求,因为它的影响范围不仅仅针对Content Pages还针对了Application Pages。因此,选项A. B直接可以排除掉了。 三、内容页是如何引用母板页的Windows SharePoint Services 提供了若干个用于引用母版页的令牌:两个动态令牌("~masterurl/default.master" 和 "~masterurl/custom.master") 两个静态令牌("~site/default.master" 和 "~sitecollection/default.master")。•动态令牌 "~masterurl/default.master"
此令牌使用 MasterPageFile 属性 (attribute) 和 MasterUrl 属性 (property) 的值从内容页引用母版页。例如,在页指令 <%@ Page MasterPageFile="~masterurl\default.master"%> 中,令牌 "~masterurl/default.master" 在运行时将替换为 MasterUrl 属性 (property) 中的值。此属性 (property) 包含母版页相对于服务器的完整路径(包含文件名)。 安装时,所有 SharePoint 内容页都使用此动态令牌并且 MasterUrl 属性 (property) 设置为 Windows SharePoint Services default.master;但是,您可以随时更改此值以指向不同的母版页。 重要提示: 整个字符串 "~masterurl/default.master" 均包含该令牌。•动态令牌 "~masterurl/custom.master"
此令牌使用 MasterPageFile 属性 (attribute) 和 CustomMasterUrl 属性 (property) 的值从内容页引用母版页。令牌 "~masterurl/custom.master" 在运行时将替换为 CustomMasterUrl 属性 (property) 的值,此属性包含母版页的相对于服务器的完整路径(包含文件名)。 默认情况下,任何 SharePoint 内容页均不使用此令牌,且此令牌仅作为具有另一个共享母版页的一种方式提供。 重要提示: 整个字符串 "~masterurl/custom.master" 均包含该令牌。•静态令牌 "~site/default.master" 和 "~sitecollection/default.master"
您可以使用这些令牌链接到相对于网站或网站集的母版页。例如,如果您的内容页位于 中,并且您使用令牌 "~sitecollection/mypage.master",则内容页将使用位于 中的母版页。如果您使用令牌 "~site/mypage.master",则内容页将使用位于 中的母版页。注意:默认情况下,MasterUrl 和 CustomMasterUrl 属性均设置为“/ _catalogs/masterpage/default.master”。如果您随后需要删除 default.master,则必须将这两个属性均设置为其他值(而不是只设置其中的一个),否则会引发一个错误,指出该 default.master 文件仍被用作该网站的母版页。(这属于选项C的知识了)
此外,您还可以通过直接更改在页指令中指定的 MasterPageFile 属性 (attribute) 的 URL,来更改内容页所使用的母版页。但与使用 MasterUrl 属性 (property) 更改母版页不同的是,它是对网页内容的更改。
有了上面的描述,我们就可以回过头来分析选项D与C了 选项D. 即是指 Content Page中的 <% @Page MasterPageFile="/_catalogs/masterpage/MyMasterPage.master" %> 设置,很明显这种设置是不符合上面四种令牌中的任何一种使用规范的, MasterPageFile属性的设置值应该使用上述的令牌规范,例如: <% @Page MasterPageFile="~masterurl/default.master" %> ,即一定要要内容页中使用”令牌”来引用母板页。另外需要注意的是 在Sharepoint2010中,如果要设置应用程序页的母板页,则已经不再这样使用MasterPageFile,而是用DynamicMasterPageFile属性来代替,当然,这点对于本题是题外话。 选项 C. 根据上面的注意点:默认情况下,MasterUrl 和 CustomMasterUrl 属性均设置为“/ _catalogs/masterpage/default.master”。如果您随后需要删除 default.master,则必须将这两个属性均设置为其他值(而不是只设置其中的一个),而且在Content Page中的 <% @Page MasterPageFile 属性的设置保持了默认的令牌,所以此修改是生效的。 所以本题目正确选项应该是C参考:
Question 24
You have a custom master page named MyApplication.master.You need to apply MyApplication.master to only a custom application page in a SharePoint site. You must achieve the goal by using the minimum amount of effort.What should you do?A. Add a custom HTTP module to the Web application that modifies the master page.B. Add a custom HTTP module to the Web application that modifies the custom application page.C. Set the MasterPageFile attribute to ~/_layouts/MyApplication.master in the @Page directive of the custom application page.D. Rename the custom application page as application.master and overwrite the default application.master page in the 14\TEMPLATE\LAYOUTS folder.解析:
本题与Question23对应,Question23是修改”内容页”的母板页,而本题则是修改”应用程序页”的母板页。而且是修改custom application page(用户自定义应用程序页)的母板页。并且:要求用最少的工作量实现目的。在Sharepoin中应用程序页引用母板页有3种情况:
1. 在 Microsoft SharePoint Foundation 中,应用程序页现在可以通过 DynamicMasterPageFile 属性继承自定义的网站母版页。所谓DynamicMasterPageFile属性就是用于代替MasterPageFile属性的。 通过使用 DynamicMasterPageFile 属性,应用程序页可引用网站母版页,而不是默认的应用程序母版页。如果需要,网站管理员可以通过管理中心或使用 SPWebApplication 对象的 MasterPageReferenceEnabled 属性,来禁止自动引用网站母版页。 2. 针对某此需要安全保护的应用程序页, 如果这些页面在加载动态母版页时遇到问题,将改为加载 _layouts 文件夹中的安全母版页。例如:• AccessDenied.aspx• MngSiteAdmin.aspx• People.aspx• RecycleBin.aspx• ReGhost.aspx• ReqAcc.aspx• Settings.aspx• UserDisp.aspx• ViewLsts.aspx3. 在自定义应用程序页上使用动态母版页如果创建自定义应用程序页,则页面必须继承自 LayoutsPageBase 基类,并且”必须”使用下面列出的动态标记之一。动态标记:•~masterurl/default.master – 应用程序页引用存储在 MasterUrl 属性中的母版页文件。•~masterurl/custom.master – 应用程序页引用存储在 CustomMasterUrl 属性中的母版页文件。 并且更为重要的是:不能在 DynamicMasterPageFile 属性中使用静态标记。 对于A. 通过HTTP module来修改母板页也是一种途径,实事上在普通的ASP.NET网站中,我们也可以通过此技术来实现母板页的修改,但对于Sharepoint平台而言,采用此技术则需要更多的步骤,最直接的首先要实现如何注入Preinit事件,然后还要再处理MasterPageFile属性的不同情况,以指向不同的MasterPage。但针对本题,此选项显然不能说是“最简单”的途径。对于B. 通过HTTP module来修改应用程序页显然是怎么也达不到修改母板页的目的的。选项D. 本选项的做法就是把应用程序页命名为母板页并覆盖原有的母板页,此方法只能用混乱来形容了。实事上,在Sharepoint2013中,借助设计管理器,您可以将 .html 文件转换为 SharePoint 2013 母版页(.master 文件)。转换后,HTML 文件和母版页相关联,因此在您编辑并保存 HTML 文件后,这些更改内容会同步到关联母版页中。但也只是针对html文件而非应用程序页(aspx页面)。选项C. 本选项对于本题应该是“相对正确”的答案,为什么这样说呢?因为实际上此方法并不适用于Sharepoint2010,正如我们上面的知识点所述,Sharepoint2010使用了DynamicMasterPageFile属性代替MasterPageFile属性,并且当在自定义应用程序页上使用动态母版页时,不能在 DynamicMasterPageFile 属性中使用静态标记。但针对Sharepoint2007,选项C的方法又的确是生效的。
所以本题目正确选项只能是C
参考: