Share via


FormComponent.ControlMode Property

Gets or sets the rendering mode for the form (display, edit, or new)

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

Public Property ControlMode As SPControlMode
    Get
    Set

Dim instance As FormComponent
Dim value As SPControlMode

value = instance.ControlMode

instance.ControlMode = value
public SPControlMode ControlMode { get; set; }

Property Value

Type: Microsoft.SharePoint.WebControls.SPControlMode

Remarks

The control can define its ControlMode property in three ways, listed in order of precedence:

  • On the control.

  • On the parent chain control, which is also a FormComponent object.

  • Based on the ControlMode property set on the page.

If a control does not specify ControlMode on the control itself, it traverses the parent chain to find a control that has set ControlMode. If no parent control is a FormComponent object with ControlMode set, the ControlMode property of the page is used.

Note

Uexpected behavior may occur when setting the ControlMode and ItemContext in OnInit (the ControlMode may be mistakenly set to the new mode). Walking up the tree to find the ControlMode fails since the control has not been added to the control tree yet and its parent control is null. For all FormComponent controls, create the ItemContext as early as possible so that child controls can get the SPContext object before the controls are added into control tree of the page (before Init). To find the control mode from parent control while parent control is null, retrieve the control mode from itemContext.FormConext.FormMode.

See Also

Reference

FormComponent Class

FormComponent Members

Microsoft.SharePoint.WebControls Namespace