我有这样的事情:
public ActionResult Create(int clubid)
{
var club = db.Clubs.Single(c=>c.Id == clubid);
ViewBag.Club = club;
Competition comp = db.Competitions.Create();
return View(comp)
}
在我的 .cshtml 中:
@Model Models.Competition
...
@Using(Html.BeginForm())
{
...
<input type="submit" value="Save" />
}
这适用于以下发布操作:
[HttpPost]
public ActionResult Create(Competition comp)
{
if (ModelState.IsValid){...}
return RedirectToAction(...);
}
但是,我想从@ViewBag.Club
对象传递一个附加参数:
[HttpPoSt]
public ActionResult Create(int clubid, Competition comp){...}
我如何在BeginForm
?