How to use multiple submit button in mvc

Jak
Jak
Member
352 Points
151 Posts

How to use multiple submit button in mvc?

Views: 8110
Total Answered: 1
Total Marked As Answer: 1
Posted On: 11-Jan-2015 14:40

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Moderator
1170 Points
210 Posts
Marked as answer      

Hi,

Try this. You can take the value of button by setting the name attribute as same to all the submit button:

@using (Html.BeginForm("Create", "Home", FormMethod.Post, new { id = "submitForm" })) { @Html.TextBoxFor(m => m.Name, new { maxlength = 50 })   <button type="submit" id="btnSave" name="command" value="Save">Save</button> <button type="submit" id="btnSubmit" name="command" value="Cancel"/> }
public ActionResult Create(YourModel obj,string command) {   //from here you can get the value of button you click if(command="Save") {   } else if(command=="Cancel") { } else { return RedirecToAction("Index"); } return View();   }
Posted On: 11-Jan-2015 14:42
banner

Blog

Active User (0)

No Active User!
 Log In to Chat