Latest MCTS 70-573 Dumps Real Exam Download 61-70

Ensurepass

QUESTION 61

You have a SharePoint site that has the URL http://contoso.com/hr.

You are creating a new Web Part.

You need to create a reference to the current subsite without having to dispose of any returned objects.

Which code segment should you use?

 

 

A. SPSite siteCollection = new SPSite(“http://www.contoso.com”);SPWebCollection site = siteCollection.AllWebs;

B. SPSite siteCollection = new SPSite(“http://www.contoso.com”);SPWeb site = siteCollection.RootWeb;

C. SPSite site = SPContext.Current.Site;

D. SPWeb site = SPContext.Current.Web;

 

Correct Answer: D Explanation/Reference:

MNEMONIC RULE: “One-line SPWeb”

NEVER dispose of anything created with the use of SPContext objects, so your choice is now limited to answers C and D.

Since you need a reference to the subsite (in SharePoint world, subsite = web), answer D is correct.

SPContext objects are managed by the SharePoint framework and should not be explicitly disposed in your code. This is true also for the SPSite and SPWeb objects returned by SPContext.Site,

SPContext.Current.Site, SPContext.Web, and SPContext.Current.Web.

Disposing Objects

http://msdn.microsoft.com/en-us/library/ee557362.aspx

 

 

QUESTION 62

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?

 

A. site.Features.Add(feature.Id);

B. site.WebApplication.WebService.Features.Add(feature.Id);

C. web.Features.Add(feature.Id);

D. web.Site.WebApplication.WebService.Features.Add(feature.Id);

 

Correct Answer: C

 

Explanation/Reference:

MNEMONIC RULE: “add feature to http://intranet/site1”

This question is confusing. site object is a SharePoint site collection with http://intranet/site1

being the root site (or root web) of this collection.

The statement “activate Feature1 in Site1 only” makes it unclear how to treat “Site1” — as a site collection or as a root web.

However, the second sentence of this question states: “Feature 1 is activated in SharePoint site”. Well, SPWeb class represents SharePoint website.

That’s why I picked Answer C, and you are free to disagree with me.

It is possible that Answer A is the correct one for this question.

 

 

clip_image002

 

A. SPWebServiceCollection webServices = new SPWebServiceCollection

(SPFarm.Local);

foreach (SPWebService myWebService1 in webServices)

{

 SPFeatureQueryResultCollection queryResults = myWebService1.QueryFeatures

(SPFeatureScope.Site, true);IEnumerator<SPFeature> featureEnumerator = queryResults.GetEnumerator();while (featureEnumerator.MoveNext()){

 SPFeature feature = featureEnumerator.Current;

feature.Upgrade(false);

}

}

B. SPWebServiceCollection webServices = new SPWebServiceCollection (SPFarm.Local);foreach (SPWebService myWebService1 in webServices){

 SPFeatureQueryResultCollection queryResults = myWebService1.QueryFeatures

(SPFeatureScope.Web, true);IEnumerator<SPFeature> featureEnumerator = queryResults.GetEnumerator();while (featureEnumerator.MoveNext()){

 SPFeature feature = featureEnumerator.Current;

feature.Upgrade(false);

}

}

C. SPSite site = SPContext.Current.Site;SPFeatureCollection allFeatures = site.Features;foreach (SPFeature currentFeature in allFeatures){

 currentFeature.Upgrade(true);

}

D. SPWeb web = SPContext.Current.Web;SPFeatureCollection allFeatures = web.Features;foreach (SPFeature currentFeature in allFeatures){

 currentFeature.Upgrade(true);

}

 

Correct Answer: A

Explanation/Reference:

MNEMONIC RULE: “large chunk of code, SPFeatureScope.Site”

Since we are working with the site collection, we need to use SPFeatureScope.Site, not SPFeatureScope.Web.

needsUpgrade (Boolean): if true, only features that need to be upgraded are included. If false, only features that do not need to be upgraded are included.

SPSite.QueryFeatures Method (Guid, Boolean) http://msdn.microsoft.com/en-us/library/ee545763.aspx

 

clip_image004

A. curRibbon.Enabled = true;

B. curRibbon.MakeRTEContextualTabsAvailable(“SP.Ribbon.ContextualTab”);

C. curRibbon.MakeTabAvailable(“SP.Ribbon.ContextualTab”);

D. curRibbon.Visible = true;

 

Correct Answer: C

Explanation/Reference:

MNEMONIC RULE: “MakeTabAvailable”

Ribbon.MakeTabAvailable Method (String) http://msdn.microsoft.com/en-us/library/ff409505.aspx

 

 

QUESTION 65

You need to create a Web Part that hides the out-of-the-box Ribbon on the current page.

Which code segment should you include in the Web Part?

 

A. SPRibbon.GetCurrent(this.Page).CommandUIVisible = false;

B. SPRibbon.GetCurrent(this.Page).Dispose();

C. this.Page.FindControl(“SPRibbon”).Dispose();

D. this.Page.FindControl(“SPRibbon”).Visible = false;

 

Correct Answer: A

Explanation/Reference:

MNEMONIC RULE: “CommandUIVisible”

There are two parts to the ribbon: the upper part, where other controls such as site actions can be put, and the CommandUI part that has the buttons and controls. This property controls the lower part of the ribbon. So, if this property is set to false, the site actions still appear in the upper part of the ribbon, but no tabs and buttons appear in the lower part.

Ribbon.CommandUIVisible Property http://msdn.microsoft.com/en-us/library/microsoft.web.commandui.ribbon.commanduivisible.aspx

 

 

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”;

 

Correct Answer: A

Explanation/Reference:

MNEMONIC RULE: ThmxTheme

ThmxTheme.SetThemeUrlForWeb Method (SPWeb, String, Boolean) http://msdn.microsoft.com/en-us/library/ee658324.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();

 

Correct Answer: A

Explanation/Reference:

MNEMONIC RULE: “DoesUserHavePermissions = RunWithElevatedPrivileges”

You need to elevate your privileges to check on current user’s permissions.

DoesUserHavePermissions?

http://www.shannonbray.com/2010/01/doesuserhavepermissions.html

 

 

QUESTION 68

You create a Web Part that contains the following code segment. (Line numbers are included for reference only.)

01 public class WebPart1 : WebPart02 {17 }

03 04  public WebPart1() {} 

05 06 07 08  protected override void CreateChildControls(){ Button clickButton = new Button(); 

09 10 11  base.CreateChildControls();} 

12 13 14  protected override void RenderContents(HtmlTextWriter writer){ 

15 16  base.RenderContents(writer);} 

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;

 

Correct Answer: C

Explanation/Reference:

MNEMONIC RULE: “create Button, then Add Button”

Create a Custom Web Part for SharePoint 2010

http://blog.concurrency.com/sharepoint/create-a-custom-web-part-for-sharepoint-2010/

SharePoint 2010 Visual Web Parts

http://httpcode.com/blogs/PermaLink,guid,357e4853-9a75-4962-ad68-1e07bcf40bb8.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.

Correct Answer: A

Explanation/Reference:

MNEMONIC RULE: “Implement Interface1 in Products Web”

Products Web Part sends ProductId; therefore, Products Web Part is the provider Web Part.

Walkthrough: Creating Connectable Web Parts in SharePoint Foundation

http://msdn.microsoft.com/en-us/library/ms469765.aspx SharePoint 2010 Provider Consumer Web Parts http://johanolivier.blogspot.com/2010/08/sharepoint-2010-provider-consumer-web.html

 

 

QUESTION 70

You plan to create one provider Web Part and two consumer Web Parts.

You need to ensure that the consumer Web Parts can receive data from the provider Web Part.

You create an interface that contains the following code segment.

public interface Interface1{

 string Parameter1 { get; set; }}

What should you do next?

 

A. Implement Interface1 in the provider Web Part.

B. Implement IWebPartField in the provider Web Part.

C. Create a set accessor for Parameter1.

D. Create a second interface and use it to communicate with the provider Web Part.

 

Correct Answer: A

Explanation/Reference:

MNEMONIC RULE: “Implement Interface1”

Walkthrough: Creating Connectable Web Parts in SharePoint Foundation http://msdn.microsoft.com/en-us/library/ms469765.aspx

SharePoint 2010 Provider Consumer Web Parts http://johanolivier.blogspot.com/2010/08/sharepoint-2010-provider-consumer-web.html

 

Download Lates MCTS 70-573 Real Free Tests , help you to pass exam 100%.