MVC newbie question; I’m learning by playing around rather than Reading The Manual… 🙂
I see when I create an “Edit” view that the auto-generated view includes a “submit” button:
<input type="submit" value="Save" />
But what code gets called behind the scenes to do this save? Specifically, the model underlying this view has its own fancy save logic in code that I would want to call. How do I get the view to invoke my code instead of whatever standard code is being called invisibly behind the scenes?
It would call whatever public action method the form action is pointing to on your controller. You can then call save on the view model.
Set your form action to
MyController/SaveYou can also use
using (Html.BeginForm...in your code to point the form to a specific action method on a specific controller.