@bobnoordam

Multiple submit buttons, and making a difference

Say we have some auto committing controls, like dropdownlist, and also a simple ‘next step’ button.How to detect a difference between the two submit events for the form ?

@Html.DropDownListFor(x => x.Option, Optionlist, new { onchange = "this.form.submit();" });
...
<button type="submit" name="submitButton" value="nextbutton">Next step</button>
  • The TYPE of the button determines it to be a form submission
  • the NAME of the button can be used as a parameter in the controller
  • the VALUE of the button can be used to detect the button from the controller
 public IActionResult Index(string submitButton, CursusselectieViewModel model) {
            if (submitButton == "nextbutton") {
                var data = new SessionData {
...