In a Razor MVC form, if you disable a html element, the value won’t be posted back to the controller.
@Html.EditorFor(model => model.Person.Surname, new { htmlAttributes = new { @class = "form-control variable" } })
You might do
if (...) { $(".variable").attr('disabled', 'disabled'); //doesn't work }
Better, do this…
if (...) { $(".disable") .prop("readonly", true) .css('color', "#c0c0c0"); //https://stackoverflow.com/a/2724483 }