====> Here is my edit.cshtml page code:
<div >
@Html.LabelFor(model => model.Eno, htmlAttributes: new { @class = "control-label col-md-2" })
<div >
@Html.EditorFor(model => model.Eno, new { htmlAttributes = new { @class = "form-control" } } )
@Html.ValidationMessageFor(model => model.Eno, "", new { @class = "text-danger" })
</div>
</div>
I want to disable this textbox. Can anyone help me with that.
This is my Controller:
[HttpGet]
public ActionResult Edit(int id)
{
Models.Employee e1 = new Models.Employee();
e1.Eno = id;
e1 = objdalemp.SearchEmp(e1);
return View(e1);
}
[HttpPost]
public ActionResult Edit(Models.Employee e1)
{
int i = objdalemp.UpdateEmployee(e1);
if(i==1)
{
return RedirectToAction("Index");
}
return View(e1);
}
CodePudding user response:
You can disable a html field generated using the following
@Html.EditorFor(model => model.Eno, new { htmlAttributes = new { @class = "form-control", @disabled = "disabled" } }).
CodePudding user response:
You can disable like below.
@Html.EditorFor(model => model.Eno, new { htmlAttributes = new { @disabled ="true", @class = "form-control" } })