Question 66
You have a custom theme named MyTheme. The theme is defined in a file named MyTheme.thmx.
You have a console application that contains the following code segment. (Line numbers are included for reference only.)
01 using (SPSite site=new SPSite(“http://intranet”))
02 {
03   SPWeb web=site.OpenWeb();
04  
05 }
You need to programmatically apply the theme to a SharePoint site.
Which code segment should you add to the console application?
A. ThmxTheme.SetThemeUrlForWeb(web, "/_catalogs/theme/MyTheme.thmx", False);
B. web.AlternateCssUrl = "/_themes/MyTheme";
C. web.ApplyWebTemplate("MyTheme.thmx");
D. web.ThemedCssFolderUrl = "/_themes/MyTheme";

解析:
 本题想要做的事情就是通过代码去实现应用一个用户定义的主题。
 直接分析各选项:
选项A. ThmxTheme.SetThemeUrlForWeb(web, "/_catalogs/theme/MyTheme.thmx", False); SetThemeUrlForWeb 方法就是用来把主题应用到URL所指定的We上的。需要注意的是:如果那个Web已经应用了某个主题,且此主题不是共享的,那么此方法将会删除掉那个已经应用的主题。
SetThemeUrlForWeb方法定义如下:
public static void SetThemeUrlForWeb(
 SPWeb web,
 string themeUrl,
 bool shareGenerated
)

因此,选项A是本题答案。
选项B. web.AlternateCssUrl = "/_themes/MyTheme";本选项完成的是设置Web site的备用样式Alternate CSS (cascading style sheet)的URL路径。与设置主题Theme无关。
选项C. web.ApplyWebTemplate("MyTheme.thmx"); 本选项使用ApplyWebTemplate方法,此方法是用来设置site definition 或site template 的,所以,本选项参数都是错误的。
选项D. web.ThemedCssFolderUrl = "/_themes/MyTheme"; 本题的ThemedCssFolderUrl属性是用来设置包含了CSS文件的文件夹所在的URL,此CCS文件是被用在主题定义中的。 所以,它是关于文件路径的设置,而不是主题的设置。
所以本题目正确选项应该是A

参考:
http://msdn.microsoft.com/en-us/library/ee658324.aspx
http://msdn.microsoft.com/en-us/library/ff409648(v=office.14).aspx

Question 67
You plan to develop a Web Part that displays a SharePoint list.
The Web Part will verify the list permissions when users access by using the web.CurrentUser.DoesUserHavePermissions method.
You need to ensure that when users do not have permissions to the list, the Web Part displays the company's logo.
Which code segment should you add to the Web Part?
A. RunWithElevatedPrivileges
B. web.AllowUnsafeUpdates= true;
C. web.CurrentUser.RequireRequestToken = false;
D. web.ValidateFormDigest();

解析:
  本题是想在一个Webpart上展现List,并受权允许的用户访问此List,对无权访问的用户则只看得到公司的logo而看不到List。
  由于在题干中已经告知代码中采用了DoesUserHavePermissions 方法完成对用户访问权限的判定,所以问题的重点就不再是让你考虑如何去完成对用户访问权限的判定了,而是在权限判定之后如何操作才能得到题目所要求的显示效果。
  于是分析各备选项:
选项A. RunWithElevatedPrivileges特权提升是 Windows SharePoint Services 3.0 中增加的一项功能,使您能够使用更高的特权级别在代码中以编程方式执行操作。利用 SPSecurity.RunWithElevatedPrivileges 方法,您可以向在帐户上下文中运行一部分代码的委托提供高于当前用户的特权,通过这个方法,对于已经判定具有访问权限的用户,可以采用此方法去获取List的内容并显示出来。而对于没有访问权限的用户,则无限去取得数据库的内容并展现在List中。选项A是本题的正解。
选项B. web.AllowUnsafeUpdates= true; 此属性是用来标识是否允许更新数据库的。 通常而言SharePoint 2010 是要阻止开发人员对 GET 请求执行状态更改操作的。例如,在使用 GET 获取列表项或 Web 属性时,不允许 Microsoft ASP.NET 页更新列表项或 Web 属性的内容。但如果您的功能设计强制对 GET 请求执行状态更改操作,则您可通过将当前 Microsoft.SharePoint.SPWeb 类的 AllowUnsafeUpdates 属性设置为 true 以禁用此检查。请记住,在执行操作后重置该属性,并使用 try-catch-finally 块以确保异常不会将该属性保持为 true。因为此项存在安全隐患,所以,微软通常建议尽量避免使用 AllowUnsafeUpdates。就本题而言,本题不是操作List更新,而是操作List展现,所以此属性不是答案。
选项C. web.CurrentUser.RequireRequestToken = false; 此属性用来标识:SPUser对象是否需要Request token。它可以用在当你开发一个Sharepoint Web Part,此Web Part将用来承载Sharepoint 外部的应用程序时,就会用到此概念。例如:在Sharepoint 的Web Part中承载Microsoft Silverlight 应用程序。关于此方面的开发,微软称之为流体应用程序模型。如果有兴趣,你可以自己去找相关资料深入研究。对于本题而言,此属性不是用来控件List的内容显示与否的。

选项D. web.ValidateFormDigest(); 用于验证当前Request的Form Digest Control的。 此属性用于和“写入”相关的操作中的。根据微软的文档: 如果传递给 RunWithElevatedPrivileges 的方法包含任何写入操作,则调用 RunWithElevatedPrivileges 之前,应该调用 SPUtility.ValidateFormDigest() 或 SPWeb.ValidateFormDigest()。所以此方法也不是本题的答案。

所以本题目正确选项应该是A

参考:
http://www.shannonbray.com/2010/01/doesuserhavepermissions.html
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.allowunsafeupdates.aspx

Question 68
You create a Web Part that contains the following code segment. (Line numbers are included for reference only.)
01 public class WebPart1 : WebPart
02 {
03   public WebPart1() {}
04  
05   protected override void CreateChildControls()
06   {
07     Button clickButton = new Button();
08    
09     base.CreateChildControls();
10   }
11  
12   protected override void RenderContents(HtmlTextWriter writer)
13   {
14    
15     base.RenderContents(writer);
16   }
17 }
You discover that the clickButton button does not appear.
You need to ensure that clickButton appears.
What should you do?
A. Delete line 09.
B. Move line 07 to line 14.
C. Add the following line of code at line 08:
Controls.Add(clickButton);
D. Add the following line of code at line 08:
clickButton.Page = this.Page;

解析:
 本题是关于编写一个WebPart,想在其中呈现一个Button。
 本题没太多好讲的, 一般在aspx页面中,习惯上要动态加载控件是放在CreateChildControl()里面的,在里面创建Control然后用this.Controls.Add()来添加。本题重载了基类的CreateChildControl()方法,在自身的CreateChildControl()方法中实现添加控件到WebPart中。
 所以,选项A.B都破坏了CreateChildControl()方法功能结构。选项D则显得非常生僻,它仿佛是想把当前Page对象赋值给包含此Button控件的Page实例。为什么要这么做,就不得而知了。但不管如何,直接操作Button所属的Page与直接操作Button好像不太相关,所以,基于此判断,选项D也不该是本题的答案。
所以本题目正确选项应该是C

参考:
http://msdn.microsoft.com/en-us/library/ee231579.aspx
http://msdn.microsoft.com/en-us/library/ms476318(v=office.14).aspx
 
Question 69
You plan to create two Web Parts named Products and ProductDetails. You create an interface that contains the following code segment.
public interface Interface1
{
    string Productid { get; set; }
}
You need to ensure that the Products Web Part sends ProductId to the ProductDetails Web Part. You must achieve this goal by using the ASP.NET Web Part connection framework.
What should you do?
A. Implement Interface1 in the Products Web Part.
B. Implement Interface1 in the ProductDetails Web Part.
C. Add a private set-accessor-declaration to the Productid property.
D. Add a protected set-accessor-declaration to the Productid property.

解析:
 本题是想要基于ASP.NET Web Part connection framework在两个Web Part之间传递数据。从题目描述可知,Product部件是信息的提供方(Provider),ProductDetails部件是信息的用户方(Consumer)。
 一般的操作步骤是先创建 Web 部件连接接口(Interface),然后创建源 Web 部件(Provider),此Provider WebPart需要实现前面创建的接口。然后再创建目标 Web 部件(Consumer),此Consumber WebPart需要在其 CreateChildControls 子例程后插入 ConnectionConsumer 属性。这样可为 ConsumerWebPart Web 部件提供连接目标接口点。然后就可以部署并在Sharepoint UI上配置建立连接了。
 所以,从上面的描述我们就可以看到,本题题干部分建立了这个接口,然后在选项中,只有选项A是在Products Web Part实现此接口(因为Product部件是Provider方)。所以选项A就是本题答案。
  至于选项C.D都只是对Productid属性变量的访问限定,并不涉及Webpart连接接口的实现,所以不是本题的答案。
所以本题目正确选项应该是A

参考:

http://msdn.microsoft.com/zh-cn/library/ff597538(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/ms469765.aspx
http://johanolivier.blogspot.com/2010/08/sharepoint-2010-provider-consumer-web.html

Sharepoint学习笔记—习题系列--70-573习题解析 -(Q66-Q69)的更多相关文章

  1. Sharepoint学习笔记—ECM系列—文档列表的Metedata Navigation与Key Filter功能的实现

    如果一个文档列表中存放了成百上千的文档,想要快速的找到你想要的还真不是件容易的事,Sharepoint提供了Metedata Navigation与Key Filter功能可以帮助我们快速的过滤和定位 ...

  2. Sharepoint学习笔记—ECM系列--文档集(Document Set)的实现

    文档集是 SharePoint Server 2010 中的一项新功能,它使组织能够管理单个可交付文档或工作产品(可包含多个文档或文件).文档集是特殊类型的文件夹,它合并了唯一的文档集属性以及文件夹和 ...

  3. Sharepoint学习笔记—习题系列--70-576习题解析 --索引目录

        Sharepoint学习笔记—习题系列--70-576习题解析  为便于查阅,这里整理并列出了70-576习题解析系列的所有问题,有些内容可能会在以后更新. 需要事先申明的是:     1. ...

  4. Sharepoint学习笔记—习题系列--70-573习题解析 --索引目录

                  Sharepoint学习笔记—习题系列--70-573习题解析 为便于查阅,这里整理并列出了我前面播客中的关于70-573习题解析系列的所有问题,有些内容可能会在以后更新, ...

  5. Deep Learning(深度学习)学习笔记整理系列之(五)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  6. Deep Learning(深度学习)学习笔记整理系列之(八)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  7. Deep Learning(深度学习)学习笔记整理系列之(七)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  8. Deep Learning(深度学习)学习笔记整理系列之(六)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  9. Deep Learning(深度学习)学习笔记整理系列之(四)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  10. Deep Learning(深度学习)学习笔记整理系列之(三)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

随机推荐

  1. Simple Molecules(简单)

    Simple Molecules time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  2. JAVA & JSON详解

    JSON定义 JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于ECMAScript的一个子集. JSON采用完全独立于语言的文本格式,但是也使用了类 ...

  3. Money类

    public class Money { /// <summary> /// 要转换的数字 /// </summary> private double j; private s ...

  4. 模拟MessageBox

    原文:<模拟MessageBox> Posted on 2014/01/07 ======================================================= ...

  5. C# 理解泛型

    出处:http://www.tracefact.net/CSharp-Programming/Generics-In-CSharp.aspx 术语表 generics:泛型type-safe:类型安全 ...

  6. 浏览器 Pointer Events

    前言 Pointer Events是一套触控输入处理规格,支持Pointer Events的浏览器包括了IE和Firefox,最近Chrome也宣布即将支持该处理规则. PointerEvent Po ...

  7. LoopBack – 开源的,可扩展的 Node.js 框架

    LoopBack 是建立在 Express 基础上的开源 Node.js 框架,专门为 Mobile,Web 和其他设备做了优化.LoopBack 能够连接到多个数据源,使用 Node.js 编写业务 ...

  8. 订餐App回顾与总结

    MY-HR 成员: 角色分配 学号 博客园 丘惠敏 PM项目经理 201406114203 http://www.cnblogs.com/qiuhuimin/ 郭明茵 用户 201406114204 ...

  9. ChartDirector应用笔记(二)

    关于Simple Bar Chart Simple bar chart是XYChart大类中的Bar chart类型中的最简单的例子.Bar chart的表现形式简单直观,在数据量较少.数据维度简单等 ...

  10. 区间合并 --- Codeforces 558D : Gess Your Way Out ! II

    D. Guess Your Way Out! II Problem's Link: http://codeforces.com/problemset/problem/558/D Mean: 一棵满二叉 ...