I have the following bit in my view :
@Html.TextBoxFor(model => model.PersonnelId, new { disabled = "disabled" })
In my controller I have this :
if (ModelState.IsValid)
{
PersonnelFacade.SavePerson(person);
return RedirectToAction("Index");
}
Now when I check the person.PersonnelId it is empty. When I remove the {disabled = "disabled" } it works fine but then I can change the PersonnelId which is not what I want to do.
What am I doing wrong?
HiddenFor+DisplayForinstead, or just addHiddenForto what you already have. Anyway, it doesn't make sense to rely on this sort of protection on browser level. Anyone can send a forged POST query withPersonnelIDchanged to what they want.