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.) 01 protected void
Page_Load(object sender, EventArgs e) 02 { 03 SPSite site = null; 04 try 05 { 06 SPSite site =
new SPSite(“http://www.contoso.com/default.aspx”); 07 SPWeb web = site.OpenWeb(); 08 09 …
10 } 11 catch 12 { 13 14 } 15 finally 16 { 17 18 } 19 } 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.) 01 protected void Page_Load(object sender, EventArgs e) 02 { 03 SPSite site =
new SPSite(“http://www.contoso.com/default.aspx”); 04 { 05 SPWeb web = site.OpenWeb(); 06
07 } 08 } 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.) 01 SPWeb recWeb =
properties.Web; 02 using (SPSite siteCollection = new SPSite(“http://site1/hr”)) 03 { 04 using
(SPWeb web = siteCollection.OpenWeb()) 05 { 06 PublishingWeb oWeb =
PublishingWeb.GetPublishingWeb(web); 07 PublishingWebCollection pubWebs =
oWeb.GetPublishingWebs(); 08 foreach (PublishingWeb iWeb in pubWebs) 09 { 10 try 11 { 12
SPFile page = web.GetFile(“/Pages/default.aspx”); 13 SPLimitedWebPartManager wpManager =
page.GetLimitedWebPartManager (PersonalizationScope.Shared); 14 } 15 finally 16 { 17 if (iWeb
!= null) 18 { 19 iWeb.Close(); 20 } 21 } 22 } 23 } 24 } You need to prevent the event receiver from
causing memory leaks. Which object should you dispose of?
You need to ensure that the code opens the dialog box
You are creating an application page that will open a dialog box. The dialog box uses a custom
master page. You write the following code segment. (Line numbers are included for reference
only.) 01 <script type=”text/javascript”> 02 function DialogCallback(dialogResult, returnValue) 03 {
04 } 05 function OpenEditDialog(id) 06 { 07 var options = { 08
url:”http://intranet/_layouts/MsgToShow.aspx, 09 width: 300, 10 height: 300, 11
dialogReturnValueCallback: DialogCallback 12 }; 13
SP.UI.ModalDialog.showModalDialog(options); 14 } 15 </script> You need to ensure that the code
opens the dialog box. What should you do?
You need to ensure that the Web Part can access the local file system on the SharePoint server
You create a Visual Web Part in SharePoint Server 2010. You need to ensure that the Web Part
can access the local file system on the SharePoint server. You must minimize the amount of
privileges assigned to the Web Part. What should you do?
What should you implement in WPMaster?
You are creating two Web Parts named WPMaster and WPDetails. You need to ensure that when
an item is selected from WPMaster, the details of the item are displayed in WPDetails. What
should you implement in WPMaster?
Which code segment should you add at line 03?
You have a SharePoint site collection that contains 100 subsites. You plan to create a Web Part.
The Web Part will be deployed to each subsite. You need to ensure that the Web Part retrieves all
of the files in the root directory of the current subsite. You write the following code segment. (Line
numbers are included for reference only.) 01 SPSite site = SPContext.Current.Site; 02 SPWeb
web = SPContext.Current.Web; 03 Which code segment should you add at line 03?
Which code segment should you add to the Web Part?
You create a Feature named Feature1. Feature1 is activated in a SharePoint site. You create a
Web Part that contains the following code. SPSite site = new SPSite(“http://intranet/site1”);
SPWeb web = site.OpenWeb(); SPFeatureDefinition feature =
SPFarm.Local.FeatureDefinitions[“Feature1”]; You need to modify the Web Part to activate
Feature1 in Site1 only. Which code segment should you add to the Web Part?
Which code segment should you use?
You have a SharePoint farm that has more than 100 custom Features. You upgrade several
Features in the farm. You need to ensure that the site collection uses the most up-to-date
versions of the Features. Only Features that require an upgrade must be evaluated. Which code
segment should you use?
Which code segment should you add at line 04?
You are creating an application. You develop a custom control that renders a contextual tab. The
control contains the following code segment. (Line numbers are included for reference only.) 01
protected override void OnPreRender(EventArgs e) 02 { 03 SPRibbon curRibbon =
SPRibbon.GetCurrent(this.Page); 04 05
curRibbon.MakeContextualGroupInitiallyVisible(“SP.Ribbon.ContextualGroup”, string.Empty); 06
base.OnPreRender(e); 07 } You need to ensure that when the custom control is rendered, the
custom contextual tab appears in the Ribbon. Which code segment should you add at line 04?