asp.net mvc custom routes with multiple submit buttons
Posted
by dangerisgo
on Stack Overflow
See other posts from Stack Overflow
or by dangerisgo
Published on 2009-07-28T13:01:47Z
Indexed on
2010/03/14
9:25 UTC
Read the original article
Hit count: 288
asp.net-mvc
|routing
So I have a custom route as such:
routes.MapRoute(
"Wizard", // Route name
"Wizard/{page}", // URL with parameters
new { controller = "Wizard", action = "Index" } // Parameter defaults
);
and have the following on my View:
<% Html.BeginForm("Continue", "Wizard"); %>
<input type="submit" value="Continue" name="Continue" />
<% Html.EndForm(); %>
In which I want to call this function:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Continue(string Number, string Rev)
{
(...)
}
but in turn when that button is pressed always calls the postback Index rather than the one I want. If I remove the custom route, it calls my function, but what I want to be displayed in the address bar is: localhost:xxxx/Wizard/1 where the number at the end is the page (div shown) of the wizard either 1, 2, 3, or 4. So is there something I'm missing or can it not be done? Thanks.
© Stack Overflow or respective owner