[Free] Get all latest Microsoft 70-515 Actual Tests 151-160

Ensurepass

QUESTION 151

You are implementing an ASP.NET application. The application includes a Person class with property Age. You add a page in which you get a list of Person objects and display the objects in a GridView control. You need to add code so that the GridView row is highlighted in red if the age of the person is less than 18. Which GridView event should you handle?

 

A.

RowDataBound

B.

RowCommand

C.

Row Updated

D.

RowEditing

 

Correct Answer: A

 

 

QUESTION 152

You are implementing an ASP.NET page that will retrieve large sets of data from a data source. You add a ListView control and a DataPager control to the page. You need to ensure that the data can be viewed one page at a time. What should you do?

 

A.

Set the DataPager control’s PageSize property to the number of rows to view at one time.

B.

Set the DataPager control’s PagedControlID property to the ID of the ListView control.

C.

In the codebehind file, set the DataPager control’s Parent property to the ListView control.

D.

In the codebehind file, set the ListView control’s Parent property to the DataPager control.

 

Correct Answer: B

 

 

QUESTION 153

You are implementing an ASP.NET Web application that retrieves data from a Microsoft SQL Server database. You add a page that includes the following data source control.

 

<asp:SqlDataSource id=”sqlds” runat=”server” ConnectionString=”<%$ ConnectionStrings:MyDB %>” SelectCommand=”SELECT * FROM Companies” />

 

The page is accessed frequently, but the data in the database rarely changes. You need to cache the retrieved data so that the database is not queried each time the Web page is accessed.

 

What should you do?

 

A.

Add the following attributes to the SqlDataSource control.

DataSourceMode=”DataSet”

EnableCaching=”True”

CacheDuration=”120″

B.

Add the following attributes to the SqlDataSource control.

DataSourceMode=”DataReader”

EnableCaching=”True”

CacheDuration=”120″

C.

Add the following configuration to the <system.web/> section of the web.config file.

<caching>

<sqlCacheDependency enabled=”true”>

<databases>

<add name=”MyDBCache” connectionStringName=”MyDB” pollTime=”120″ /> </databases>

</sqlCacheDependency>

</caching>

D.

Add the following configuration to the <system.web/> section of the web.config file.

<caching>

<sqlCacheDependency enabled=”true” pollTime=”120″> <databases>

<add name=”MyDBCache” connectionStringName=”MyDB” /> </databases>

</sqlCacheDependency>

</caching>

 

Correct Answer: A

 

 

QUESTION 154

You are implementing an ASP.NET application that uses LINQ to Entities to access and update the database. The application includes the following method to update a detached entity of type Person.

 

private NorthwindContext _entities;

 

public void UpdatePerson(Person personToEdit)

 

{

 

}

 

You need to implement the UpdatePerson method to update the database row that corresponds to the personToEdit object.

 

Which code segment should you use?

 

A.

_entities.People.Attach(personToEdit);

_entities.ObjectStateManager.ChangeObjectState(

personToEdit,

EntityState.Modified);

_entities.SaveChanges();

B.

_entities.ObjectStateManager.ChangeObjectState( personToEdit,

EntityState.Added);

_entities.SaveChanges();

C.

_entities.People.ApplyCurrentValues(personToEdit); _entities.SaveChanges();

_entities.People.Attach(new Person() { Id = personToEdit.Id });

D.

_entities.ObjectStateManager.ChangeObjectState( personToEdit,

EntityState.Modified);

_entities.SaveChanges();

 

Correct Answer: A

Explanation:

Table(Of TEntity).Attach Method (TEntity)

(http://msdn.microsoft.com/en-us/library/bb300517.aspx)

 

 

QUESTION 155

You are implementing an ASP.NET Web site. The Web site contains a Web service named ProductService . The code-behind file for the ProductService class contains the following code segment.

 

public class ProductService :

 

System.Web.Services.WebService

 

{

 

public List<Product> GetProducts( int categoryID )

 

{

 

return GetProductsFromDatabase(categoryID);

 

}

 

}

 

You need to ensure that the GetProducts method can be called by using AJAX.

 

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

 

A.

Apply the WebService attribute to the ProductService class.

B.

Apply the ScriptService attribute to the ProductService class.

C.

Apply the WebMethod attribute to the GetProducts method.

D.

Apply the ScriptMethod attribute to the GetProducts method.

 

Correct Answer: BC

Explanation:

CHAPTER 9 Working with Client-Side Scripting, AJAX, and jQuery Lesson 3: Implementing jQuery

Calling a Web Service with $.ajax() (page 535)

CHAPTER 10 Writing and Working with HTTP Modules and Web Services Lesson 2: Creating and Consuming XML Web Services Calling a Web Service from Client Script by Using AJAX (page 583-584)

 

 

QUESTION 156

You create a new ASP.NET MVC 2 Web application. The following default routes are created in the Global.asax.cs file. (Line numbers are included for reference only.)

 

01 public static void RegisterRoutes(RouteCollection routes)

 

02 {

 

03 routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);

 

04

 

05 routes.MapRoute( “Default”, “{controller}/{action}/{id}”, new { controller = “Home”, action = “Index”, id = “” } );

 

06 }

 

You implement a controller named HomeController that includes methods with the following signatures.

 

public ActionResult About()

 

public ActionResult Index()

 

public ActionResult Details(int id)

 

You need to ensure that the About action is invoked when the root URL of the site is accessed.

 

What should you do?

 

A.

At line 04 in the Global.asax.cs file, add the following line of code. routes.MapRoute(“Default4Empty”, “/”, new {controller = “Home”, action = “About”});

B.

At line 04 in the Global.asax.cs file, add the following line of code. routes.MapRoute(“Default”, “”, new {controller = “Home”, action = “About”});

C.

Replace line 05 in the Global.asax.cs file with the following line of code. routes.MapRoute(“Default4Empty”, “{controller}/{action}/{id}”, new {controller = “Home”, action = “About”, id = “”});

D.

Replace line 05 in the Global.asax.cs file with the following line of code. routes.MapRoute(“Default”, “{controller}/{action}”, new {controller = “Home”, action = “About”});

 

Correct Answer: C

 

 

QUESTION 157

You are implementing an ASP.NET MVC 2 Web application. The URL with path /Home/Details/{country} will return a page that provides information about the named country. You need to ensure that requests for this URL that contain an unrecognized country value will not be processed by the Details action of HomeController. What should you do?

 

A.

Add the ValidateAntiForgeryToken attribute to the Details action method.

B.

Add the Bind attribute to the country parameter of the Details action method.

Set the attribute# s Prefix property to Country.

C.

Create a class that implements the IRouteConstraint interface.

Configure the default route to use this class.

D.

Create a class that implements the IRouteHandler interface.

Configure the default route to use this class.

 

Correct Answer: C

 

 

QUESTION 158

You are implementing an ASP.NET MVC 2 Web application. A controller contains the following code.

 

public ActionResult Edit(int id)

 

{

 

return View(SelectUserToEdit(id));

 

}

 

public ActionResult Edit(Person person)

 

{

 

UpdateUser(person);

 

return RedirectToAction(“Index”);

 

}

 

The first Edit action displays the user whose details are to be edited, and the second Edit action is called when the Save button on the editing form is clicked to update the user details. An exception is thrown at run time stating that the request for action Edit is ambiguous. You need to correct this error and ensure that the controller functions as expected. What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

 

A.

Add the following attribute to the first Edit action.

[AcceptVerbs(HttpVerbs.Head)]

B.

Add the following attribute to the first Edit action.

[HttpGet]

C.

Add the following attribute to the second Edit action.

[HttpPost]

D.

Add the following attribute to the second Edit action.

[HttpPut]

 

Correct Answer: BC

Explanation:

There is no [HttpPut] attribute.

[AcceptVerbs] represents an attribute that specifies which HTTP verbs an action method will respond to. The possible variants are HttpVerbs enumeration: Get, Post, Put, Delete, Head.

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

CHAPTER 14 Creating Websites with ASP.NET MVC 2

Lesson 2: Creating Models, Views, and Controllers

 

 

QUESTION 159

You are implementing an ASP.NET MVC 2 Web application. You create a shared user control named MenuBar.ascx that contains the application# s menu. You need to use the menu bar in all application views. What should you do?

 

A.

In the site# s master page, create a div element with an ID of Navigation. Add the following code segment inside this div element. <% Html.RenderPartial (“~/Views/Shared/MenuBar.ascx”); %>

B.

In the site# s master page, create a div element with an ID of Navigation. Add the following code segment inside this div element. <%= Url.Content ( “~/Views/Shared/ MenuBar.ascx “) %>

C.

In each of the controller# s action methods, add an entry to the ViewData collection with a key of Navigation and a value of ~/Views/Shared/MenuBar.ascx.

D.

In the site# s Global.asax.cs file, register a route named Navigation that points to the ~/Views/Shared/MenuBar.ascx file.

 

Correct Answer: A

 

 

QUESTION 160

You create an ASP.NET MVC 2 Web application that contains the following controller class.

 

public class ProductController : Controller

 

{

 

static List<Product> products = new List<Product>();

 

public ActionResult Index()

 

{

 

return View();

 

}}

 

In the Views folder of your application, you add a view page named Index.aspx that includes the following @ Page directive.

 

<%@ Page Inherits=”System.Web.Mvc.ViewPage” %>

 

You test the application with a browser. You receive the following error message when the Index method is invoked: “The view ‘Index’ or its master was not found.”

 

You need to resolve the error so that the new view is displayed when the Index method is invoked.

 

What should you do?

 

A.

Change the name of the Index.aspx file to Product.aspx.

B.

Create a folder named Product inside the Views folder. Move Index.aspx to the Product folder.

C.

Replace the @ Page directive in Index.aspx with the following value. <%@ Page Inherits=”System.Web.Mvc.ViewPage<Product>” %>

D.

Modify the Index method by changing its signature to the following:

public ActionResult Index(Product p)

 

Correct Answer: B

 

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

Instant Access to Try Microsoft 70-515 Free Demo

This entry was posted in 70-515 Actual Tests and tagged , , , , , . Bookmark the permalink.