Generic Field Control
The Generic Field Control is a special Field Control that renders the default Field Controls for the Fields of the displayed Content. Default Field Control for a Field is defined by the Field implementation (see supported Field Controls section for each Field) and can be overridden in the Content Type Definition of the displayed Content.
The Generic Field Control automatically resolves the default Field Control for a given Field and renders it. Not only does it render a single Field Control, but Field Controls for all Fields defined in the CTD of the Content - except when explicitely given to skip specific Field Controls. This makes it a useful tool when creating Content Views that use a generic layout for the Field Controls.
The Generic Field Control will list all defined Fields of the Content using the default Field Control. The default Field Control for a Field is defined by the Field itself , from code (see supported Field Controls section for each Field) - but can be set with the ControlHint property in the Field Setting.
Fields are listed according to the order of the Fields defined in the CTD. Please note, that Field order can be changed by overriding a Field a child Content Type. Above that, Field order can be configured using the FieldsOrder property (see #Properties).
Visible Fields are controlled by the visibility settings in the CTD (VisibleBrowse, VisibleEdit, VisibleNew). Fields marked as Hide are not listed; Advanced Fields are put under the Show advanced fields section and are hidden by default. For further information please refer to:
Above that, the Generic Field Control can be configured to skip specific Fields using the ExcludedFields property (see #Properties).
Generic Content View
There is a special Content View type defined in the base system called the Generic Content View. It has similar functionality except that it is less configurable than the Generic Field Control and strictly relies upon CTD settings.
- ContentListFieldsOnly: lists only the Fields that were defined with a List. See Content Views for FormItem Content Type.
- FieldsOrder: space separated list of Fields that will be displayed in the exact order that is given by this list.
- ReadonlyFields: space spearated list of Fields that will be rendered read only.
- ExcludedFields: space separated list of Fields that will NOT be rendered.
The following code is an excerpt from the User Content Type's Edit Content View. It includes a couple of manually defined Field Controls and a Generic Field Control.
<%@ Control Language="C#" AutoEventWireup="true" Inherits="SenseNet.Portal.UI.SingleContentView" %> <div class="sn-user"> <div class="sn-user-prop"> <div class="sn-user-edit"><sn:ShortText runat="server" ID="ShortTextFullName" FieldName="FullName" /></div> <div class="sn-user-edit"><sn:ShortText runat="server" ID="ShortTextDomain" FieldName="Domain" /></div> <div class="sn-user-edit"><sn:ShortText runat="server" ID="ShortTextName" FieldName="Name" /></div> <div class="sn-user-edit"><sn:ShortText runat="server" ID="ShortTextEmail" FieldName="Email" /></div> <div class="sn-user-edit"><sn:GenericFieldControl runat="server" ID="GenericFieldControl1" ExcludedFields="Avatar FullName Domain Name Email Version Index Password" /></div> <div class="sn-user-edit"><sn:CommandButtons ID="CommandButtons1" runat="server" /></div> </div> </div>
The following example shows how to give Field Control ordering:
<sn:GenericFieldControl runat="server" ID="GenericFieldcontrol1" FieldsOrder="DisplayName Description FirstLevelApprover FirstLevelTimeFrame SecondLevelApprover SecondLevelTimeFrame WaitForAll" />
The following line will list the Fields of the current item Content that are defined in a parent List - Fields that start with '#'.
<sn:GenericFieldControl runat=server ID="GenericFieldControl1" ContentListFieldsOnly="true" />