In MVC we have the crucial information that is used to perform the operation in our project like the primary id of the entities we are working upon.
For this we need to hide this information from the external interface but need to store it internally for our use.
@Html.HiddenFor is one of the controls in MVC that is used for this purpose.
We hide the crucial details into this control and use it whenver needed.
@model Modal_PopUp_Basic.Models.EmployeeModel
@using (Html.BeginForm("SaveDetails","Home",new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>EmployeeModel</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="col-md-10">
@Html.HiddenFor(model => model.EmpId, new { htmlAttributes = new { @class = "form-control" },id="hddnid" })
</div>
</div>
Here we have stored the id of the employee into the @Html.HiddenFor control.
We can access it like any other control in MVC .
0 Comment(s)