You are developing an ASP.NET MVC2 view and controller.
The application includes a class names Employee that has a LastName property. The controller requires an
action method that will insert an Employee
instance into a database.
You need to ensure that the data that is submitted is an Employee instance and that a LastName value is
given.
What should you do?
A.
Add a ValidationMessage helper method immediatelyafter the view’s last name TextBox. Define the action
method as follows.
public ActionResult Create(FormCollection employeeToCreate)
{…}
B.
Add the Required attribute to the LastName property. Define the action method as follows.
public ActionResult Create(FormCollection employeeToCreate)
{…}
C.
Add the Required attribute to the LastName property. Define the action method as follows.
public ActionResult Create(Employee employeeToCreate)
{…}
D.
Add the ValidationMessage helper method immediately after the views last name TextBox. Define the
action method as follows.
public ActionResult Create(Employee employeeToCreate)
{…}