Hari Gillala
Hari Gillala

Reputation: 11926

Access HiddenFor(Model=>Model.Id) MVC ASP.NET in Controller

How do I access the following written in View

 @Html.HiddenFor(Model=>Model.id)

in Controller ?

Thank you

Upvotes: 1

Views: 1292

Answers (1)

Eranga
Eranga

Reputation: 32447

Create a Action method that takes the Type that you used as Model in your view.

[HttpPost]
public ActionResult Create(MyModel model)
{
   var id = model.id;//the id in @Html.HiddenFor(Model=>Model.id)
}

Upvotes: 2

Related Questions