i have a field that i want to make not editable for the users. its a field of type text.
I have a 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 are iam doing wrong, why does this code hide the field in the forms? Iam not sure but is it possible to make a field "non editable" programmatically?