nerdexam
Microsoft

70-515 · Question #45

You are implementing an ASP.NET MVC 2 Web application that contains the following class. public class DepartmentController : Controller { static List<Department> departments = new…

The correct answer is A. <%= Html.Action("ListEmployees", Model) %>. Html.Action(string, object) invokes a child action method and returns the result as an HTML ChildActionExtensions.Action Method Html.DisplayForModel() Method returns HTML markup for each property in the model. Html.DisplayForModel(string, object) Method returns HTML markup for…

Consume WCF services

Question

You are implementing an ASP.NET MVC 2 Web application that contains the following class. public class DepartmentController : Controller { static List<Department> departments = new List<Department>(); public ActionResult Index() { return View(departments); } public ActionResult Details(int id) { return View(departments.Find(x => x.ID==id)); } public ActionResult ListEmployees(Department d) { List<Employee> employees = GetEmployees(d); return View(employees); } } You create a strongly typed view that displays details for a Department instance. You want the view to also include a listing of department employees. You need to write a code segment that will call the ListEmployees action method and output the results in place. Which code segment should you use?

Options

  • A<%= Html.Action("ListEmployees", Model) %>
  • B<%= Html.ActionLink("ListEmployees", "Department",
  • C<% Html.RenderPartial("ListEmployees", Model); %>
  • D<%= Html.DisplayForModel("ListEmployees") %>

How the community answered

(28 responses)
  • A
    79% (22)
  • B
    14% (4)
  • C
    4% (1)
  • D
    4% (1)

Explanation

Html.Action(string, object) invokes a child action method and returns the result as an HTML ChildActionExtensions.Action Method Html.DisplayForModel() Method returns HTML markup for each property in the model. Html.DisplayForModel(string, object) Method returns HTML markup for each property in the model, using the specified template and additional view data. RenderPartialExtensions.RenderPartial Method us/library/system.web.mvc.html.renderpartialextensions.renderpartial.aspx) The ActionLink method renders an element that links to an action method. LinkExtensions.ActionLink Method

Topics

#ASP.NET MVC#Html.Action#child actions#strongly typed view

Community Discussion

No community discussion yet for this question.

Full 70-515 Practice