SPField.ReadOnlyField property
SharePoint 2013
Gets or sets a Boolean value that specifies whether values in the field can be modified.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Property value
Type: System.Booleantrue to specify that the field cannot be modified; otherwise, false.
The following code example makes a field read-only in a specified list on a root Web site.
using (SPSite oSiteCollection = new SPSite("http://MyServer")) { using (SPWeb oWebsite = oSiteCollection.OpenWeb()) { SPList oList = oWebsite.Lists["MyList"]; SPListItem oItem = oList.Items[0]; oItem.Fields["MyField"].ReadOnlyField = true; oItem.Fields["MyField"].Update(); } }
Note
|
|---|
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects. |
Note