Question 86


2.3.3 Question

Multiple Choice

You are modifying an ASP.NET MVC web application and you have created a new master layout page named _Layout.WindowsPhone.cshtml. You want to use that layout in a new view. Which code segment do you use?

  • A. @Html.ActionLink("_Layout.WindowsPhone.cshtml");
  • B. Layout="~/Views/Shared/_Layout.WindowsPhone.cshtml";
  • C. Layout="Layout.WindowsPhone.cshtml";
  • D. @Html.Partial("_Layout.WindowsPhone.cshtml");

Answer:

B
Explanation
A. Incorrect: @Html.ActionLink creates a clickable link and does not do anything to set the layout.
B. Correct: Layout="" loads the layout file to be used with that view.
C. Incorrect: Layout="Layout.WindowsPhone.cshtml" points to an incorrect view folder.
D. Incorrect: @Html.Partial loads. a partial view, but does not manage the layout being used by the page.