Sharepoint学习笔记—习题系列--70-573习题解析 -(Q25-Q27)

Question25
You develop a new publishing page layout named MyPage.aspx for a SharePoint site.
You create an Elements.xml file.

Elements.xml contains the following code segment. (Line numbers are included for reference only.)
01 <File Url="mypage.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
02 <Property Name="Title" Value="MyPage" />
03 <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
04 <Property Name="PublishingAssociatedContentType" Value="; 05 #$Resources:cmscore,contenttype_page_name;;
06 #0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811;#"/>
07
08 </File>
You need to prevent users from creating pages based on the page layout.
Which property tag should you add at line 07?

A. <Property Name="Hidden" Value="True" />
B. <Property Name="PublishingHidden" Value="True" />
C. <Property Name="RequireSiteAdministrator" Value="False" />
D. <Property Name="Rights" Value="ViewListItems" />

解析:
 本题的要求就是禁用你创建的页面布局MyPage.aspx。
页面布局(Page Layout) 是一个模板,将其与母版页结合使用可控制页面的外观和内容。每个页面布局都有一个关联的内容类型,该内容类型决定可存储在基于页面布局的页面上的内容类型。
  默认情况下,SharePoint Server 2010 将创建每个网站的母版页样式库;但是,只能使用网站集(Site Collection)的首要网站(Top level site)的母版页样式库(Master Page Gallery)中所存储的页面布局来创建新的页面。
   创建页面布局时,会创建一个 SharePoint 使用的 .aspx 文件(即本题中的MyPage.aspx),并且会向该页面布局的 HTML 版本添加一些 HTML 标记。
   在用VS2010创建一个页面布局时,我们可以清楚地看到其Element.xml的组织结构.如下示例代码

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="PageLayoutsModule"
          Url="_catalogs/masterpage">
    <File Path="PageLayoutsModuleTermsPageLayout.aspx"
          Url="TermsPageLayout.aspx"
          Type="GhostableInLibrary">
      <Property Name="ContentType"                Value="$Resources:cmscore,contenttype_pagelayout_name;"/>
      <Property Name="PublishingAssociatedContentType"
                Value=";#TermsAndConditionsType;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390035e07eba31844ff5bd10e36808ad5efd;#"/>
      <Property Name="Title"
                Value="Terms and Conditions Page"/>
    </File>
  </Module>
</Elements>

即Element下套着Module元素,Module元素下套着File元素,File元素下套着Property元素。
本例就是要在Page Layout 这种Content Type所有应该具有的Property (或Internal Field)中寻找答案。(所有的Page Layouts必须继承自"Page Layout" content type,我们在上述Elements.xml的代码中用Resource file 值来指定:<Property Name="ContentType"                Value="$Resources:cmscore,contenttype_pagelayout_name;"/>)。

选项A.  Hidden,此属性是Content Type Class所具备的属性,表示此Content Type是否允许在用户界面直接创建或使用。它影响到Create Content Type 时的Page,而不是Create 一个Page Layout时的Page。
选项B. PublishingHidden,通过设置此属性,我们能够实现在Create Page页面所提供的可使用的Page Layout列表中,隐藏特定的Page Layout。这正是我们本题想要的功能。所以也是本题的答案。此属于也适用 于母版页隐藏。

选项C. RequireSiteAdministrator, 此属性是LayoutsPageBase类所具备的属性,用于标识是否只允许site collection administrators (网站集管理员)访问此页面。所以本选项也是不对的。
选项D.  ViewListItems属于Microsoft.SharePoint程序集下的SPBasePermissions 枚举值,属于Sharepoint权限管理的一部分,比如用于RoleDefinition的设置定义。本题此处的ViewListItems是指允许查看ListItem.不条例本题要求。
所以本题目正确选项应该是B

http://msdn.microsoft.com/zh-cn/library/ms544928(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/ms459213.aspx
http://msdn.microsoft.com/en-us/library/ms462994.aspx
http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.client.contenttype_properties.aspx
http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopmentprevious/thread/45e1782a-dbe7-4513-bafd-e84de61dfe7d http://community.bamboosolutions.com/blogs/sharepoint-2010/archive/2011/11/23/sharepoint-2010-cookbook-how-to-create-custom-page-layout-for-publishing-site-using-visual-studio-2010.aspx
 

Question26
You have a SharePoint site collection. The default master page for the site collection displays a navigation bar on the left side of the page.
You create a custom content page.
You need to hide the navigation bar on only the custom content page.
What should you do?
A. On the default master page, remove the ContentPlaceHolder control that has the ID PlaceHolderLeftNavBar.
B. On the default master page, set the Visible attribute to False in the ContentPlaceHolder control that has the ID PlaceHolderLeftNavBar.
C. Add an empty Content control to the custom content page and set the ContentPlaceHolderID attribute to PlaceHolderLeftNavBar.
D. Add a Content control to the custom content page, set the ContentPlaceHolderID attribute to PlaceHolderLeftNavBar, and set the Visible attribute to False.

解析:
本题的意思是要隐藏特定用户内容页面上的导航条(此导航条属于此内容页面所属的母板页的一部分),且仅针对此特定内容页面。
 光从题意就首先可以排除A.B选项了,因为它们都是基于Master page做修改,而所有针对Master Page的修改必须影响到所有调用此Master Page的页面。
 所以问题集中到了选项C与D。我们可以通过在特定页面上放置Content Control来覆盖掉在Master Page定义的相应ContentPlaceHolder Control,这种修改是个性化的,它只影响到被修改的Content Page本身。
具有迷惑性是选项D,它所作的操作是在你的Content Page上放置 Content Control并命名为你想要覆盖的ContentPlaceHolder Control的ID,失败就发生在你设置了它的Visible属性,当你设置此属性为False时,Sharepoint根本就不会Render此部分的内容,那么你想要Override位于Master Page上的对应的ContentPlaceHolder Control的意图就完全落空了。(事实是:你可以在Master Page中找到ContentPlaceHolder Control,通过设置它的Visible属性为False或者移到某个不可见的区域来达到隐藏此控件的目的,但这样的修改必然会影响到所有引用此母板页的页面)。
所以本题目正确选项应该是C :通过放置一个空的Content Control来实现既覆盖又不显示的双重目的。

参考:
http://www.sdtimes.com/SHARE_POINTERS_USING_A_PAGE_LAYOUT_TO_HIDE_THE_LEFT_NAVIGATION/By_Ryan_Keller/33596
http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.contentplaceholder.aspx


Question 27
You develop a custom master page.
You need to ensure that all pages that use the master page contain a specific image.
Page developers must be able to change the image on individual pages. The master page must be compatible with the default content page.
What should you add to the master page?
A. a ContentPlaceHolder control
B. a Delegate control
C. a PlaceHolder control
D. an HTML Div element

解析:
 本题要求是:1.开发人员可以在各个不同的页面上修改”镶嵌”于母板页上的图片。2. 修改图片之后,内容页与母板页不会发生冲突。
 它考的其实就是ContentPlaceHolder(占位符),
Sharepoint母版页包含显示在所有页上的静态文本和控件,还包含一个或多个 ContentPlaceholder 控件。内容占位符定义内容页中存储的信息的显示区域。自定义母版页必须与默认母版页具有相同的控件和内容占位符。
在 Microsoft SharePoint Foundation 中,应用程序和内容页的内容占位符现在是相同的。通过使用相同的内容占位符,内容和应用程序页可以使用相同的母版页,以便在整个网站中获得更一致的外观。
根据本题题意:
 1.你想要使此图片最初作用到所有引用母板页的页面,所以就必须在母板页中放置存放图片的占位符。
 2.你想对某些页面作个性修改,则只需要在这些页面再放置Content Control并命名为你想要覆盖的那个存放图片的ContentPlaceHolder就行了。
 3.所谓内容页与母板页在个性化修改后不会发生冲突,就是指你不能在作了个性化修改后,再去删除或修改母板页上的这个ContentPlaceHolder。
 因此本题答案是 A.
 选项B. 委托控制提供了一种指定特定功能的候选控件的方法,并为这些控件选择功能提供程序。Sharepoint的Delegate Control就像一个容器,它封装了各种默认的控件在里面。这些控件可以被用户开发的自定义控件进行替换,从而达到用户自定义的功能和效果。
   SharePoint 提供了不少的delegate controls:
    •AdditionalPageHead
    •GlobalSiteLink0
    •GlobalSiteLink1
    •GlobalSiteLink2
    •PublishingConsole
    •QuickLaunchDataSource
    •SmallSearchInputBox
    •TopNavigationDataSource
上面所列举的Delegate controls可以在运行时被用户自定义的控件或Feature动态替换。所以很明显,基于Delegate control的实现必需至少要已经有对应的Control在母板页上存在,而且也不可能在每个引用此母板页的页面上个性化再定义自己的Control,因此,选项B不对。
选项C. PlaceHolder Control这是普通ASP.NET网站技术的概念。基本思路就是先放置一个空的容器(an empty container control)在页面上,然后在运行时动态地加载此容器内的子元素。 实现思路和ContentPlaceHolder一致,但不属于Sharepoint的技术内容。
D. an HTML Div element 就完全是定制化了,根本做不到母板页与引用页面的融合。
所以本题目正确选项应该是A

参考:
http://msdn.microsoft.com/zh-cn/library/ee537576(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.contentplaceholder.aspx
http://msdn.microsoft.com/zh-cn/library/ms478826.aspx
http://www.cnblogs.com/wsdj-ITtech/archive/2011/11/26/2263041.html
http://msdn.microsoft.com/zh-cn/library/tety77hf(v=vs.71).aspx

原文地址:https://www.cnblogs.com/wsdj-ITtech/p/3137147.html