This Method directly hits the Action defined in the formaction="actionName" and type of mehtod as defined in formmethod="methodName".
Solution 2:
<input type="submit" name="save" value="Save" />
<input type="submit" name="cancel" value="Cancel" />
There are two submit buttons - one with name attribute set to save and the other with name of cancel. When you click a particular button, its name and value is sent to the server. The ActionName() action needs to grab these values to detect which one was clicked.
[HttpPost] public ActionResult ActionName(Customer obj, string save,string cancel) { if(!string.IsNullOrEmpty(save)) { ViewBag.Message = "Customer saved successfully!"; } if (!string.IsNullOrEmpty(cancel)) { ViewBag.Message = "The operation was cancelled!"; } return View("Result",obj);