If you use the PAGE method in SharePoint, whether it is the new field or the old field editing, it cannot set whether the field is creating NewForm. aspx, display DispForm. aspx, edit EditForm. the aspx page is displayed. The SharePoint object model allows you to easily implement this function. Each field includes ShowInDisplayForm, ShowInEditForm, and ShowInNewForm attributes. Use true and False to set whether to display the fields, the ShowInListSettings attribute is used to set whether the field is displayed on the "List Settings" page.
Now we will specify a field in the notification list in the new NewForm. aspx, display DispForm. aspx, edit EditForm. aspx and "list Settings" page display, C # code is as follows:
/// <Summary> /// set whether the field is displayed on the corresponding page. /// </summary> /// <param name = "web"> </param> /// <param name = "listName"> </param> protected void SetFieldShowPage (SPWeb web, string listName) {SPList list = web. lists [listName]; Microsoft. sharePoint. SPField field = list. fields. getField ("txtField"); // The field is not in DispForm. field is displayed on the aspx page. showInDisplayForm = false; // The field is in EditForm. field is displayed on the aspx page. showInEditForm = true; // The field is not in NewForm. field is displayed on the aspx page. showInNewForm = false; // The field is displayed on the list settings page. showInListSettings = true; // The field is displayed in the view. showInViewForms = true; field. update ();}
In the above Code, list is used. fields. getField ("txtField"); to obtain the Field object SPField with the specified name. When GetField is used to obtain the field, you can input an internal name or display name of the field.
After getting the SPField object, you can use the attribute settings to check whether the attributes are displayed on the corresponding page. The specific meaning of each attribute has been commented out in the Code, finally, you must use the Update () method of SPField to save the changes to the database.
Field. ShowInDisplayForm = false is used. The field cannot be displayed on the "view Projects" page, as shown in figure 1:
See: http://www.360sps.com/item/38eb9bbe217a46bea5d276525ab8b0e4.aspx for the original with diagram