Home » [Free] Get all latest Microsoft 70-515 Actual Tests 171-180

[Free] Get all latest Microsoft 70-515 Actual Tests 171-180

Ensurepass

QUESTION 171

You are implementing custom ASP.NET server controls. You have a base class named RotaryGaugeControl and two subclasses named CompassGaugeControl and SpeedGaugeControl. Each control requires its own client JavaScript code in order to function properly. The JavaScript includes functions that are used to create the proper HTML elements for the control. You need to ensure that the JavaScript for each of these controls that is used in an ASP.NET page is included in the generated HTML page only once, even if the ASP.NET page uses multiple instances of the given control. What should you do?

 

A.

Place the JavaScript in a file named controls.js and add the following code line to the Page_Load method of each control.

Page.ClientScript.RegisterClientScriptInclude(this.GetType(), “script”, “controls.js”);

B.

Add the following code line to the Page_Load method of each control, where strJavascript contains the JavaScript code for the control. Page.ClientScript.RegisterClientScriptBlock(this.GetType(), “script”, strJavascript);

C.

Add the following code line to the Page_Load method of each control, where CLASSNAME is the name of the control class and strJavascript contains the JavaScript code for the control.

Page.ClientScript.RegisterStartupScript(typeof(CLASSNAME), “script”, strJavascript);

D.

Add the following code line to the Page_Load method of each control, where CLASSNAME is the name of the control class and strJavascript contains the JavaScript code for the control.

Page.ClientScript.RegisterClientScriptBlock(typeof(CLASSNAME), “script”, strJavascript);

 

Correct Answer: D

 

 

 

 

 

 

QUESTION 172

You are implementing an ASP.NET application. You add the following code segment.

 

clip_image001

 

You need to add code to return a list of all Person objects except those with a UserId that is contained in the secretUsers list. The resulting list must not contain duplicates.

 

Which code segment should you use?

 

A.

var secretPeople = (from p in allPeople

from u in secretUsers

where p.UserId == u

select p).Distinct();

return allPeople.Except(secretPeople);

B.

return from p in allPeople

from u in secretUsers

where p.UserId != u

select p;

C.

return (from p in allPeople

from u in secretUsers

where p.UserId != u

select p).Distinct();

D.

List<Person> people = new List<Person>(

from p in allPeople

from u in secretUsers

where p.UserId != u

select p);

return people.Distinct();

 

Correct Answer: A

 

 

QUESTION 173

You are implementing an ASP.NET application. You add the following code segment.

 

Public Function GetNonSecretUsers() As List(Of Person)

 

Dim secretUsers() As String =

 

{“@secretUser”, “@admin”, “@root”}

 

Dim allpeople As List(Of Person) = GetAllPeople()

 

 

End Function

 

You need to add code to return a list of all Person objects except those with a UserId that is contained in the secretUsers list. The resulting list must not contain duplicates.

 

Which code segment should you use?

 

A.

Dim secretPeople = (From p In allpeople

From u In secretUsers

Where p.UserId = u

Select p).Distinct()

Return allpeople.Except(secretPeople)

B.

Return From p In allpeople

From u In secretUsers

Where p.UserId <> u

Select p

C.

Return (From p In allpeople

From u In secretUsers

Where p.UserId <> u

Select p).Distinct()

D.

Dim people As List(Of Person) = New List(Of Person)( From p In allpeople

From u In secretUsers

Where p.UserId <> u

Select p) Return people.Distinct()

 

Correct Answer: A

 

 

QUESTION 174

You are implementing an ASP.NET Web site. The site contains the following class.

 

public class Address

 

{

 

public int AddressType;

 

public string Line1;

 

public string Line2;

 

public string City;

 

public string ZipPostalCode;

 

}

 

The Web site interacts with an external data service that requires Address instances to be given in the following XML format.

 

<Address AddressType=”2″>

 

<Line1>250 Race Court</Line1>

 

<City>Chicago</City>

 

<PostalCode>60603</PostalCode>

 

</Address>

 

You need to ensure that Address instances that are serialized by the XmlSerializer class meet the XML format requirements of the external data service.

 

Which two actions should you perform (Each correct answer presents part of the solution. Choose two.)

 

A.

Add the following attribute to the AddressType field.

[XmlAttribute]

B.

Add the following attribute to the Line2 field.

[XmlElement(IsNullable=true)]

C.

Add the following attribute to the ZipPostalCode field.

[XmlAttribute(“ZipCode”)]

D.

Add the following attribute to the ZipPostalCode field.

[XmlElement(“ZipCode”)]

 

Correct Answer: AD

Explanation:

XmlSerializer Class

(http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx)

 

 

QUESTION 175

You are implementing a new Dynamic Data Web site. The Web site includes a Web page that has an ObjectDataSource control named ObjectDataSource1. ObjectDataSource1 interacts with a Web service that exposes methods for listing and editing instances of a cla named Product. You add a GridView control named GridView1 to the page, and you specify that GridView1 should use ObjectDataSource1 as its data source. You then configure GridView1 to auto-generate fields and to enable editing. You need to add Dynamic Data behavior to GridView1. You also must ensure that users can use GridView1 to update Product instances. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

 

A.

Add a DynamicDataManager control to the Web page.

B.

Disable the auto-generated fields on GridView1. Add a DynamicField control for each field of the Product class.

C.

Add the following code segment to the Application_Start method in the Global.asax.cs file.

DefaultModel.RegisterContext(

typeof(System.Web.UI.WebControls.ObjectDataSource), new ContextConfiguration() {ScaffoldAllTables = true});

D.

Add the following code segment to the Page_Init method of the Web page.

GridView1.EnableDynamicData(typeof(Product));

 

Correct Answer: BD

Explanation:

CHAPTER 12 Working with Data Source Controls and Data-Bound Controls Lesson 3: Working with ASP.NET Dynamic Data

Enabling Dynamic Data Inside a Webpage (page 778)

 

 

QUESTION 176

You are implementing an ASP.NET MVC 2 Web application that allows users to view and edit data. You need to ensure that only logged-in users can access the Edit action of the controller. What are two possible attributes that you can add to the Edit action to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

 

A.

[Authorize(Users = “”)]

B.

[Authorize(Roles = “”)]

C.

[Authorize(Users = “*”)]

D.

[Authorize(Roles = “*”)]

 

Correct Answer: AB

Explanation:

[Authorize(…)] represents an attribute that is used to restrict access by callers to an action method. Possible arguments: Order, Roles, Users, TypeId. When you mark an action method with AuthorizeAttribute, access to that action method is restricted to users who are both authenticated and authorized. If you mark a controller with the attribute, all action methods in the controller are restricted. The Authorize attribute lets you indicate that authorization is restricted to predefined roles

 

or to individual users. This gives you a high degree of control over who is authorized to view any page on the site.

If an unauthorized user tries to access a method that is marked with the Authorize attribute, the MVC framework returns a 401 HTTP status code. If the site is configured to use ASP.NET forms authentication, the 401 status code causes the browser to redirect the user to the login page.

 

AuthorizeAttribute Class

(http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute.aspx)

 

The following example shows several ways to use AuthorizeAttribute. The HomeController class has three action methods that are marked with the Authorize attribute, and two that are not marked. On the AuthenticatedUsers method, the attribute limits access to users who are logged in. On the AdministratorsOnly method, the attribute limits access to users who have been assigned to either the Admin role or the Super User role. On the SpecificUserOnly method, the attribute limits access to the users whose names are Betty or Johnny. The Index and About methods can be accessed by anyone, even anonymous users.

 

[HandleError]

public class HomeController : Controller

{

public ActionResult Index() {

ViewData[“Message”] = “Welcome to ASP.NET MVC!”; return View();

}

public ActionResult About() {

return View();

}

[Authorize]

public ActionResult AuthenticatedUsers() {

return View();

}

[Authorize(Roles = “Admin, Super User”)]

public ActionResult AdministratorsOnly() {

return View();

}

[Authorize(Users = “Betty, Johnny”)]

public ActionResult SpecificUserOnly() {

return View();

 

}

}

 

QUESTION 177

You create an ASP.NET MVC 2 Web application. You implement a single project area in the application. In the Areas folder, you add a subfolder named Test. You add files named TestController.cs and Details.aspx to the appropriate subfolders. You register the area’s route, setting the route name to test_default and the area name to test. You create a view named Info.aspx that is outside the test areA. You need to add a link to Info.aspx that points to Details. aspx. Which code segment should you use?

 

A.

<%= Html.RouteLink(“Test”, “test_default”, new {area = “test”}, null) %>

B.

<%= Html.ActionLink(“Test”, “Details”, “Test”, new {area = “test”}, null) %>

C.

<a href=”<%= Html.RouteLink(“Test”, “test_default”, new {area = “test”}, null) %>”>Test</a>

D.

<a href=”<%= Html.ActionLink(“Test”, “Details”, “Test”, new {area = “test”}, null) %>”>Test</a>

 

Correct Answer: B

 

 

QUESTION 178

You are implementing a read-only page that includes the following controls.

 

clip_image003

 

You disable view state to improve performance.

 

You need to ensure that the page is updated to display the latest data when the user clicks the refresh button.

 

Which code segment should you use?

 

A.

protected void Page_PreInit(object sender, EventArgs e) {

if (!IsPostBack)

{

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

}

B.

protected void Page_Load(object sender, EventArgs e) {

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

C.

protected void gvCustomers_DataBinding(object sender, EventArgs e) {

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

D.

protected void Page_PreRender(object sender, EventArgs e) { if (!IsPostBack)

{

gvCustomers.DataSource = GetCustomers();

gvCustomers.DataBind();

}

}

 

Correct Answer: B

 

QUESTION 179

You are implementing an ASP.NET page that hosts a user control named CachedControl. You need to ensure that the content of the user control is cached for 10 seconds and that it is regenerated when fetched after the 10 seconds elapse. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

 

A.

Modify the hosting page’s caching directive as follows.

<%@ OutputCache Duration=”10″ VaryByParam=”None” %>

B.

Add the following meta tag to the Head section of the hosting page.

<meta http-equiv=”refresh” content=”10″>

C.

Add the following caching directive to the hosted control.

<%@ OutputCache Duration=”10″ VaryByParam=”None” %>

D.

Add the following caching directive to the hosted control.

<%@ OutputCache Duration=”10″ VaryByControl=”None” %>

 

Correct Answer: AC

Explanation:

CHAPTER 2 Using Master Pages, Themes, and Caching Lesson 3: Caching

Page Output Caching (page 83)

HTTP-EQUIV Attribute | httpEquiv Property

(http://msdn.microsoft.com/en-us/library/ms533876(v=vs.85).aspx) meta http-equiv gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header.

 

Examples:

This example causes the browser to reload the document every two seconds.

<meta http-equiv=”refresh” content=”2″>

This example sets the character set for the document.

<meta http-equiv=”Content-Type”

content=”text/html; charset=utf-8″>

This example disables theme support for the document. <meta http-equiv=”msthemecompatible” content=”no”> This example tells Internet Explorer to display a webpage in IE9 mode, if possible. <meta http-equiv=”X-UA-Compatible” content=”IE=9″>

 

 

QUESTION 180

You create a Web page that has an ASP.NET menu. You need to ensure that the menu items are populated from an array of strings in your code-behind file. What should you do?

 

A.

Write a JavaScript function that uses document.write to write out an asp:MenuItem for each string array element.

B.

In the Page_Render handler, use Response.Write to write out an asp:MenuItem for each string array element.

C.

Set the DataSource attribute of asp:Menu to the name of the array.

D.

In the Page_Load handler, create an instance of asp:MenuItem for each string array element, and add each of these instances to the menu’s Items collection.

 

Correct Answer: D

 

Instant Access to Download Testing Software & PDF File for Microsoft 70-515 Real Exam

Instant Access to Try Microsoft 70-515 Free Demo

HOT EXAM!

Name of author

Name: admin