I have a field that I want to make not editable for the users. It's a field of type Text
.
I have read about doing it with javascript and content editor webbpart, but I want to do it programmatically because the field is part of my Feature.
I have tried this code, but it hides the field in forms view:
SPList list = web.lists["caseslist"];
SPField field = list.Fields.GetField("casenumbers");
field.ReadOnlyField = true;
field.ShowInDisplayForm = true;
field.ShowInEditForm = true;
field.ShowInNewForm = true;
field.Update();
What am I doing wrong, why does this code hide the field in the forms?
I am not sure but is it possible to make a field "non editable" programmatically?