Which code segment should you add?
You have a Web application that contains the following code segment. Private Sub
CreatingSPSite() Dim siteCollection As SPSite = Nothing Try siteCollection = New
SPSite(“http://contoso.com”) Finally End Try End Sub You need to prevent the code segment
from causing a memory leak. Which code segment should you add?
You need to modify the code in WebPart1 to prevent the pages from loading slowly
You deploy a custom Web Part named WebPart1 to a SharePoint site. WebPart1 contains the
following code segment. (Line numbers are included for reference only.) 01Protected Sub
Page_Load(ByVal sender As Object, ByVal e As EventArgs) 02 Dim site As SPSite = Nothing 03
Try 04Dim site As New SPSite(“http://www.contoso.com/default.aspx”) 05 Dim web As SPWeb =
site.OpenWeb() 06 07 … 08 Catch 09 10 Finally 11 12 End Try 13End Sub After you deploy
WebPart1, users report that the pages on the site load slowly. You retract WebPart1 from the site.
Users report that the pages on the site load without delay. You need to modify the code in
WebPart1 to prevent the pages from loading slowly. What should you do?
You need to modify the Web Part to prevent the site from loading slowly
You have a Web Part that contains the following code segment. (Line numbers are included for
reference only.) 01Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 02
Dim site As New SPSite(“http://www.contoso.com/default.aspx”) 03 If True Then 04 Dim web As
SPWeb = site.OpenWeb() 05 06 End If 07End Sub You deploy the Web Part to a SharePoint site.
After you deploy the Web Part, users report that the site loads slowly. You need to modify the
Web Part to prevent the site from loading slowly. What should you do?
Which object should you dispose of?
You create an event receiver. The ItemAdded method for the event receiver contains the following
code segment. (Line numbers are included for reference only.) 01Dim recWeb As SPWeb =
properties.Web 02 Using siteCollection As New SPSite(“http://site1/hr”) 03 Using web As SPWeb
= siteCollection.OpenWeb() 04 Dim oWeb As PublishingWeb =
PublishingWeb.GetPublishingWeb(web) 05 Dim pubWebs As PublishingWebCollection =
oWeb.GetPublishingWebs() 06 For Each iWeb As PublishingWeb In pubWebs 07 Try 08 Dim
page As SPFile = web.GetFile(“/Pages/default.aspx”) 09 Dim wpManager As
SPLimitedWebPartManager = page.GetLimitedWebPartManager(PersonalizationScope.[Shared])
10 Finally 11 If iWeb IsNot Nothing Then 12 iWeb.Close() 13 End If 14 End Try 15 Next 16 End
Using 17 End Using You need to prevent the event receiver from causing memory leaks. Which
object should you dispose of?
You need to add a modal dialog box to a SharePoint application
You need to add a modal dialog box to a SharePoint application. What should you use?
Which code segment should you add to the Custom Action node of the Elements.xml file?
You plan to add a custom tab to the Ribbon in a SharePoint Web application. You create a
custom Feature that contains an Elements.xml file. You need to ensure that the custom tab only
appears in the document libraries of the Web application. Which code segment should you add to
the Custom Action node of the Elements.xml file?
You need to create a Feature that adds a custom button to the Documents tab on the Ribbon of one site collecti
You have one Web application that contains several SharePoint site collections. You need to
create a Feature that adds a custom button to the Documents tab on the Ribbon of one site
collection only. What should you do?
Which element should you use in the Feature?
You create a Feature. You need 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?
You need to apply MyApplication.master to only a custom application page in a SharePoint site
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?
Which property tag should you add at line 07?
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
#0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE8
11;#”/> 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?