Form in View
@using (Html.BeginForm(FormMethod.Post))
{
<input type="text" id="txbxName">
<input type="submit" value="Insert" name="Command">
<input type="submit" value="Edit" name="Command">
}
Controller Code
Method 1 :
[HttpPost]
public ActionResult FormSubmit(FormModel model, string Command)
{
if (Command == "Insert")
{
//Your
Code
}
else if(Command =="Edit")
{
//Your
Code
}
}
Method 2 :
[HttpPost]
[SubmitButton(MatchFormKey = "Command", MatchFormValue = "Insert")]
public ActionResult FormSubmit(FormModel model, string Command)
{
//Your
Code
}
[HttpPost]
[SubmitButton(MatchFormKey = "Command", MatchFormValue = "Edit")]
public ActionResult
FormSubmit(FormModel model, string Command)
{
//Your
Code
}
No comments:
Post a Comment