two submit buttons on a form

后端 未结 2 1768
天涯浪人
天涯浪人 2021-01-28 00:18

lets say I have a set of establishments, each establishments know who his father is and a establishment can have many childs. now I created a set of cascading dropdowns for this

2条回答
  •  忘掉有多难
    2021-01-28 00:47

    You can't, essentially. The script that makes the AJAX form an AJAX form binds to the submit event, so any submit will be caught.

    Remember all the HTML helpers and controls in ASP.NET are there to cover common scenarios and make your life easier when you're actually in a common scenario. The more "custom" your code gets (such as a second submit button that will do a regular POST instead of an AJAX POST), the more work you need to do (and the less you should be using the builtin helpers and controls).

    Just create a regular form (Html.BeginForm), add your two submit buttons, and then attach a click event on the AJAX version, and then send the POST as AJAX yourself.

提交回复
热议问题