Export (0) Print
Expand All

Field Controls and Control Templates

In addition to Web Parts, pages in Microsoft Office SharePoint Server 2007 can contain field controls. Field controls are simple Microsoft ASP.NET 2.0 controls that you can create. They have a small amount of code to display the two modes of the controls: one for render time, and one for edit time.

Windows SharePoint Services 3.0 and Office SharePoint Server 2007 provide several default field controls that you can use in your pages. All field controls that you use in an Office SharePoint Server 2007 site derive from a base class in Windows SharePoint Services 3.0 named FormComponent. You can extend any of the default Windows SharePoint Services 3.0 and Office SharePoint Server 2007 controls for your own specific functionality.

You can write a field control of your own by deriving from BaseRichField class, or you can write a field control that derives from the default field controls.

Control templates are an ASP.NET 2.0 feature that separates data from presentation. Templates define the presentation of the control, and all field controls contained in sites use templates for layout definition.

As a developer, you can do the following:

  • Create and deploy a control template.

  • Deploy a template that overrides a default control template.

  • Edit a template after it is deployed.

Control template definition is similar to field type definition, and it follows the same extensibility and deployment model.

All custom templates are added to the NewTemplates.ascx file. You can define the control template for a custom field control in one of three ways:

  • Set the control template for the control programmatically by using the GetControlTemplate method in the object model.

  • Set the TemplateName or AlternateTemplateName attribute in the instance of the field control on a page.

  • Instead of defining a template file and referencing it in the control, define the template in the markup of the control itself. This technique is available mostly for Web designers who do not have permissions to install new templates but want to customize the look and feel of a control.

As Office SharePoint Server 2007 is currently configured, at run time a site uses templates in the following order, depending on how they were defined: markup, TemplateName attribute, and GetControlTemplate method. Template designers can modify this behavior, however, by overriding the GetControlTemplate method. All controls derived from the FormComponent base class can override the GetControlTemplate method to define how a control chooses which template to use. The template logic is then used by all instances of the control.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft