I work with MVC5 in C#. I use Code First connection. I want hide my model's US_ID component in view. When I click edit button see this ResultImage result. I want US_ID textbox visible=false. But I can't do it.
I follow below code in my web application : // I wrote this code in controller
[HttpPost]
public ActionResult EditUser(WebApplication3.Models.UserAccount usr)
{
using (OurDbContext db = new OurDbContext())
{
db.Entry<WebApplication3.Models.UserAccount>(usr).State = System.Data.Entity.EntityState.Modified;
name = usr.US_NAME;
pass = usr.US_PASS;
db.SaveChanges();
}
return RedirectToAction("Index");
}
<body id="body" style="background-color:#c9d7e8;">
<div>
@using (Html.BeginForm())
{
@Html.HiddenFor(model => model.US_ID)
@Html.EditorForModel("UserAccount")
<br />
<input type="submit" value="Yenilə" />
}
</div>
</body>
Put this attribute on top of the property that you do not want to show: