Reputation: 14204
I am writing an app using ASP.NET MVC. I'm in a view that is located at:/orders/{orderId}
. That view renders just fine. Inside of it though, I have a button inside of a form that looks like this:
<form action="/orders/{orderId}/flag" method="post">
<button type="submit" class="btn">Flag</button>
</form>
In my controller, I have the following:
public class OrdersController : Controller
{
public ActionResult Details(string id)
{
var model = Orders.FindById(id);
return View(model);
}
public ActionResult Flag(string id)
{
var model = Orders.FindById(id);
model.Flag();
return RedirectToAction(
}
}
My question is, how do I use the ASP.NET MVC helpers to generate the path to my flag action? The action in my form is just a template at the moment which won't work. How do I address this scenario in my razor view?
Thanks!
Upvotes: 1
Views: 1028
Reputation: 3073
@Url.Action("Flag", "Orders", new { id = [orderid here] })
I recommend using T4MVC, the you can do:
@Url.Action(MVC.Orders.Flag([orderid here])
Upvotes: 1