How should you implement model binding for the ReservationLocation type?

DRAG DROP
You are developing an ASP.NET MVC web application in Visual Studio 2012.

The application has a model named ReservationLocation that contains properties named City and
State.
The view that displays reservations has a single text box named loc for entering the location
information. The location is entered as city, state.
There are action methods that have ReservationLocation as a parameter type.
You need to ensure that the City and State properties are correctly populated.
How should you implement model binding for the ReservationLocation type? (To answer, drag the
appropriate code segment to the correct location or locations. Each code segment may be used
once, more than once, or not at all. You may need to drag the split bar between panes or scroll to
view content.)





DRAG DROP
You are developing an ASP.NET MVC web application in Visual Studio 2012.

The application has a model named ReservationLocation that contains properties named City and
State.
The view that displays reservations has a single text box named loc for entering the location
information. The location is entered as city, state.
There are action methods that have ReservationLocation as a parameter type.
You need to ensure that the City and State properties are correctly populated.
How should you implement model binding for the ReservationLocation type? (To answer, drag the
appropriate code segment to the correct location or locations. Each code segment may be used
once, more than once, or not at all. You may need to drag the split bar between panes or scroll to
view content.)





Answer: See the explanation

Explanation:







Leave a Reply 1

Your email address will not be published. Required fields are marked *


sac

sac

Correct:
var raw = …
data = raw … Split()

Reason:
– The data result has to be an array based on creation of new ReservationLocation with data[0] and [1], and data must be populated.
– data = … GetValue() is not an array, so data = raw … Split() must be used
– raw = … the only possible line to create and assign value
So basically there is no other option. 🙂