开发者

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 @.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜