I am using ASP.NET Entity Framework and I have this text field, which is disabled:
@Html.TextBoxFor(model => model.consultant, new { @class = "form-control", disabled = "disabled" })
I have this on the Edit page, but when I goto save it, it updates consultant column as an empty string.
Here is the method code:
[HttpPost]
[ValidateAntiForgeryToken]
[Authorize]
public ActionResult Edit([Bind(Include = "id,consultant,image,message,startStop")] SetupClass setupClass)
{
string[] username = User.Identity.Name.Split('\\');
ViewBag.User = username[0];
ViewBag.Renderings = dbRendering.Data.OrderBy(m => m.order).ToList();
if (ModelState.IsValid)
{
db.Entry(setupClass).State = EntityState.Modified;
db.SaveChanges();
ViewBag.Message = "Updated";
return View(setupClass);
}
return View(setupClass);
}
I guess I could exclude the consultant column from the method as I don't need to update it at all.