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

Question 11
You have a Web page named ShowMessage.aspx.
You create a new Web page.
You need to display the content from ShowMessage.aspx in an IFRAME on the new Web page. You must achieve this goal by using the minimum amount of effort.

What should you do?
A. Add a FormView Web Part that displays ShowMessage.aspx.
B. Use Response.Write to write text to the browser.
C. Use SP.UI.ModalDialog.showModalDialog() to display a dialog.
D. Use Response.Redirect to send users to the ShowMessage.aspx page.

解析:
 本题要求你在一个页面中用Iframe方式显示另一个页面的内容,并且要求工作量最少。
选项A. 使用FormView Web Part,因为此类Webpart主要是用于和数据库数据打交道,用于显示,更新数据库数据的,所以不适合。
选项B. Response.Write方法用于向当前的HTTP输出写入特定的字符串。如下格式:
<H3 align=center>I just want to say <% Response.Write "Hello World.</H3><BR>" %> 
Your name is: <% Response.Write Request.QueryString("name") %> <BR>
 它并不能接受另一个URL的页面地址为参数并显示那个页面,所以此选项也并不适合。
选项D. Response.Redirect,使用此方法可以显示指定的URL页面内容,示例如下:
Response.RedirectLocation = "Put The Target Page URL";
Response.StatusCode = 301;
但这种显示却并不是基于IFRAME的,因此也不适合本题。
此外,微软推荐使用的是SPUtility.Redirect 在Sharepoint中代替Response.Redirect方法。因为它提供了更多的选择参数。
选项C. SP.UI.ModalDialog.showModalDialog() 此方法会根据你提供的相关参数(包括其它页面的URL)显示一个模态窗口,如下某个示例:

<script language="javascript" type="text/javascript">
    function OpenDialogUsing_showModalDialog() {
        var dialogOptions = SP.UI.$create_DialogOptions();
        dialogOptions.url = '/sites/cs/md/Pages/PageinDialog.aspx';
        dialogOptions.width = 650;
        dialogOptions.height = 300;
        SP.UI.ModalDialog.showModalDialog(dialogOptions);
        return false;
    }
</script>
<a href="#" onclick="javascript:OpenDialogUsing_showModalDialog(); return false;" id="htmlAnchor">showModalDialog</a>

 

所以,选项C是本题的答案。


参考
http://msdn.microsoft.com/zh-cn/library/ff410058(v=office.14).aspx
https://www.nothingbutsharepoint.com/sites/devwiki/SP2007Dev/Pages/How%20to%20use%20SPUtility.Redirect.aspx
http://www.chaholl.com/archive/2010/11/17/using-the-dialog-framework-in-sharepoint-2010.aspx


Question12
You create a modal dialog that displays a list of items.
You need to capture the items selected by a user.
Which code segment should you use?
A. SPItem item = SPContext.Current.Item;
B. var items = SP.ListOperation.Current.Item();
C. var items = SP.ListOperation.Selection.getSelectedItems();
D. var item = SPContext.Current.Item["Selected"];

解析:
 本题的实质就是考你在Sharepoint中如何返回List被选中的Items。
Sharepoint提供了SP.ListOperation.Selection.getSelectedItems()方法来返回List被选中的Items。此方法的返回值是一组键/值对,其中键(Key)是基于0开始计算的索引,值(Value)是一个包含两个属性的对象,两个属性就是 id和 fsObjType, 其中 id就是List Item的ID ,fsObjType 就是此Item的类型,0 = 是list item 或 document, 1= 是文件夹,所以本题目正确选项应该是C
  选项A. SPContext.Current.Item, 返回是当前List的当前Item,(要根据给定的List ID与Item ID确定),如果在上下文丢失了ID,则会出现报错,这也是为什么网上有人反应通过使用SPContext.Current.List 或 SPContext.Current.Item 找不到当前List或当前List的Item的原因,但不管怎样,它返回的都不可能返回你当前选择的若干个List Items.
  选项B. SP.ListOperation命名空间下就只有Selection类成员,找不到Current类,所以选项B是根本不存在的。
  选项D. SPContext.Current.Item["Selected"],即使能返回值,也只是返回指定List的指定Item中的某个名为”Selected”的Column的值,而并不是被选中的Item的对象集。
所以本题目正确选项应该是C

参考
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontext.item.aspx
http://msdn.microsoft.com/en-us/library/ff409526.aspx


Question 13
You need to add a modal dialog box to a SharePoint application.
What should you use?
A. the Core.js JavaScript
B. the Microsoft.SharePoint assembly
C. the Microsoft.SharePoint.Client assembly
D. the SP.js JavaScript

解析:
 本题考的是如何在Sharepoint中引入showModalDialog功能,ModalDialog属于Sharepoint的客户端ECMAScript对象模型,当你在Sharepoint网站的Webpart页面或者application页面(aspx page)上使用ECMAScript对象模型时,你只需要引用SP.js就可以了。
 Sharepoint提供了两个版本的Sp.js (即:Sp.js与Sp.debug.js)。它们通过Sharepoint网站的MasterPage里的scriptmanager来加载。默认情况下Scriptmanager的ScriptMode设置为auto,即自动加载Sp.js。如果你想要加载Debug版本,你需要修改web.config中的<system.web> 节下的<deployment retail="false" /> 。
  当然,当你部署到生产机时,你必须加载Sp.js而不是Sp.debug.js。
选项 A. Core.js,  Sharepoint2010的运行在很大程度上依赖于Javascript,而Core.js则包含了许多Sharepoint的运行任务,尤其是上下文菜单。如下面一些功能就是依赖于Core.js中定义的javascript功能:
 GetFirstChildElement(e)
GetLastChildElement(e)
GetCBSelectedValues(frm)
createNewDocumentWithProgID(strTemplate, strSaveLocation, strProgID, bXMLForm)
 选项B. Microsoft.SharePoint assembly 提供的是关于top-level site 和其下面的subsite或lists的相关类型与成员。是Sharepoint服务器端的最重要组件之一。没有它,Sharepoint平台就完全不能运行了。
 选项C. the Microsoft.SharePoint.Client assembly。若要使 你开发的Windows 窗体、Windows Presentation Foundation (WPF) 或其他调用 .NET 托管 SharePoint Foundation 客户端 API 的应用程序能正常工作,则客户端计算机必须已安装 (引用)上述位置的SharePoint Foundation 客户端 DLL ,你必须同时具有 Microsoft.SharePoint.Client.dll 和 Microsoft.SharePoint.Client.Runtime.dll 才能使用 .NET 托管对象模型远程开发解决方案。也就是说:若要在客户端计算机上使用包含 .NET 托管客户端 API 的 DLL,必须使用 Microsoft 的 随应用程序一起分发它们。
  显然,B与C都与模态窗口的功能无关。
所以本题目正确选项应该是D

参考
http://msdn.microsoft.com/en-us/library/ee538253.aspx
http://www.cnblogs.com/wsdj-ITtech/archive/2013/03/18/2559413.html


Question 14
You are developing an application page.
You need to create a pop-up window that uses the ECMAScript object model.
Which namespace should you use?
A. SP.UI.Menu
B. SP.UI.ModalDialog
C. SP.UI.Notify
D. SP.UI.PopoutMenu

解析:
还是关于模态窗口的题,如果看了前面的资料,几乎不用思索就选B了,因为SP.UI.ModalDialog类就是用于Sharepoint的模态窗口功能的。
  选项A. 在命名究竟SP.UI下只有如下的类:
AspMenu :   Represents an AspMenu control.
Dialog:   Represents a dialog.
DialogHostedWindow: This class and its members are reserved for internal use and are not intended to be used in your code.
ModalDialog:  Represents a modal dialog.
Notify:   Provides methods for managing notification alerts.
PopoutMenu:  Defines a pop-out menu.
Status:   Provides methods for managing status messages.
Workspace:  Represents a workspace area.
根本不存在所谓的命名空间SP.UI.Menu,所以此选项是错误的。
  选项C.D  从上面的列举可以知道SP.UI.Notify 用于显示notification alerts消息的。 SP.UI.PopoutMenu用于显示pop-out菜单,二者都和显示模态窗口无关。
所以本题目正确选项应该是B
参考:
http://msdn.microsoft.com/en-us/library/ee552096(v=office.14).aspx
http://www.a2zmenu.com/Blogs/sharepoint/SharePoint%202010%20Model%20Dialog.aspx

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值