In the NerdDinner MVC app demo, there is confirmButton defined when setting up ActionResult Delete:
public ActionResult Delete(int id, string confirmButton) {
What is confirmButton for, as it is not used in the code? I assumed it returned the name of the submit button that was clicked, but it is just a blank string. How can you get which button was pressed (e.g. you could have archive and a delete (or yes , no) buttons on the same page)?
If you look at the View
Delete.aspxyou’ll see the following html…As you can see the confirmButton is located here and the value will be passed to the ActionResult you specified.
You can also specify two buttons like…
The
confirmButtonparameter will have the value of whichever one you clicked…Why it isn’t working properly for you in NerdDinner is strange though but you can easily test this by creating a quick project and opening the default HomeController and adding
In the Index.aspx you can add
And you should be good to go.