ASP.NET MVC3: model binding with hidden field
Here's the view
@using (Html.BeginForm("Deleted", "Location"))
{
Html.Hidden("LocationID", Model.LocationID );
<input type = "submit" value = "Delete" />
}
And here's the method that's supposed to receive the data.
public ActionResult Deleted(int LocationID)
{
//Do something with Loca开发者_StackOverflow中文版tionID
return View();
}
When I run the code, LocationID is always null. Am I missing something?
Thanks for helping
Calling Html.Hidden
returns an IHtmlString
containing a hidden field.
However, you aren't doing anything with the returned string.
You need to render the string to the page using an @
.
精彩评论