How would I get both param1 and param2 to my controller, I tried like this but only param1 gets passed.
@using (Ajax.BeginForm("Index", "Controller", new { param1 = 0 }, new AjaxOptions { UpdateTargetId = "Target", InsertionMode = InsertionMode.Replace, OnFailure = "error" }))
{
<input type="submit" name="param2" value="1" />
//more buttons
}
public ActionResult Index(int param1, int param2)
{
//do something
}
@using (Ajax.BeginForm("Index", "Controller", new { param1 = 0 }, new AjaxOptions { UpdateTargetId = "Target", InsertionMode = InsertionMode.Replace, OnFailure = "error" }))
{
<input type="submit" name="param2" id="param2" value="1" />
//more buttons
}
public ActionResult Index(String param1, String param2)
{
//do something
}
Is not it working ??
To set params like this:
@using (Ajax.BeginForm("Index", "myController", new { param1 = 0, param2 = 1 }, new AjaxOptions { UpdateTargetId = "Target", InsertionMode = InsertionMode.Replace, OnFailure = "error" }))
{
<input type="submit" />
//more buttons
}
public ActionResult Index(String param1, String param2)
{
//do something
}
you MUST map the relative route in the RouteConfig.sc
before the `default' mapRoute :
routes.MapRoute(
name: "routeName",
url: "myController/Index/{param1}/{param2}",
defaults: new { controller = "myController", action = "Index", param1 = UrlParameter.Optional, param2 = UrlParameter.Optional }
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With