I am using ASP.NET MVC 3.
I have a view that accepts a view model of type EditGrantApplicationViewModel. In this view model I have properties. When the view is loaded for the first time I pass it an instance of this view model:
public ActionResult Create()
{
EditGrantApplicationViewModel viewModel = new EditGrantApplicationViewModel();
return View(viewModel);
}
On this view I have my submit button that takes the form values and adds it to the database. I also have another button on this view, but it doesn't have to be clicked, and when clicked, it takes the employee number, does a database lookup and gets the employee's details. This data is returned to te same view and prepopulates this view with the data so that the user doesn't have to type in the data. The data can either be retrieved this way or can be manually entered.
Then the user can go on and type in the other fields and edit any of the fields that were returned from the lookup. When doen then the user can click submit to add it to the database. How would I do something like this? Would I require to forms on my page, one going to the Create action method and the other going to GetEmployee action method to do the database lookup? Should I use multiple form on my page? If so is having multiple forms a best practice? Any code samples would be appreciated :)