Data Haunting

Easy Solutions Destination


Various way to handle multiple submit buttons in MVC

In MVC we have requirements like there are multiple submit buttons on same form . As we are used to handle single button on same form , here we will see how to handle multiple submit buttons like save , save and continue and cancel on same form with various method .

Suppose we have one Inquiry form with various submit button like below.

For the above situations now we will discuss various method to handle multiple submit buttons on same form .

Handle Multiple submit buttons using Request Parameter in MVC

For above snippets our view will be as per below.

Now to handle all this submit buttons at controller side we will use Request parameter . In Request parameter we will pass “name” attribute of all submit buttons to check for particular button click .

Handle Multiple Submit Buttons based on different value provided in submit Buttons

For this type we will use different values for different submit buttons but same name attribute like “Command” . View for this method.

Check command value at Controller side.

What is your opinion ?

By following above method we can differentiate multiple submit buttons and easily can handle . If you have any query you can comment or you can mail me.

Leave a Reply