10.4. Implementing Custom Field Controls in Page Layouts

With a custom field type and/or field control created, now everything needs to be deployed into the proper locations before it can be used within content types and page layouts:

  1. Deploy the assembly containing the field type, value, and control to the GAC.

  2. Place the rendering template (CountryRegionControl.ascx) in the [..]\12\TEMPLATE\CONTROLTEMPLATES folder.

  3. Copy the field type definition (fldtypes_wrox.xml) in the [..]\12\TEMPLATE\XML folder.

  4. Add a safe control entry into the web.config file of the Web application of the site that will use the field type to indicate to SharePoint that the objects in the deployed assembly are safe.

Another option is to deploy the field type and all associated files using WSS solution packages. The downloadable code for the book demonstrates this approach.

After deploying all the necessary files related to the field type and/or control to the appropriate locations, recycle the Web services on the server by typing the following at a command prompt: iisreset exe.

Recycling the Web server rather than the application pool is necessary because SharePoint loads field controls only when all the services start up. Once the Web services start, a developer can then designate a new field as a site column and add it to a content type. The custom field type will appear in the radio button list of field types when creating a new site column, as shown in Figure 10-10

Figure 10-10. Figure 10-10

With the ...

Get Professional SharePoint® 2007 Web Content Management Development: Building Publishing Sites with Office SharePoint Server 2007 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.