Home » Microsoft » 70-486 v.2 » How should you complete the relevant code?
HOTSPOT
You develop an ASP.NET MVC application that includes the following class. Line numbers are included for reference only.
You must use the Razor view engine to display all property values for the class.
You need to implement the view.
How should you complete the relevant code? To answer, select the appropriate code segment from each list in the answer area.
Hot Area:
Correct Answer:
Explanation/Reference:
Explanation:
The @model directive provides a clean and concise way to reference strongly-typed models from view files. Box 1: @Model.Name
Box 2: @foreach (var item in Model.Friends) Box 3: @item
We can pass only one argument to the Razor template and it can be accessed through the @item parameter. Reference: http://prideparrot.com/blog/archive/2012/9/simplifying_html_generation_using_razor_templates http://odetocode.com/ blogs/scott/archive/2013/01/09/ten-tricks-for-razor-views.aspx
My answer is:
1. @Model.Name
2. @foreach …
3. @item.Name
agree !!
I think the correct answer for the last drop-down is: “@item.Name” and not the one that is provided in response. If we use “@item”, on UI will be displayed the object type instead the object value and I think this is not the expected behavior for a normal user