
108
❘
CHAPTER 5 Custom Field types, Content types, and list deFinitions
field, you can leverage the base classes rendering template for editing. In other instances in which
you require a customized edit experience and display experience, you would likely define a second
RenderTemplate in this file for editing.
Creating the SSN Field Control
The SSN Field Control handles the display of the eld type in all forms and also handles validation
of the control. To modify the SSN Field Control, follow these steps:
1. Open SSNFieldControl.cs in Visual Studio.
2. Add the following using statements to the top of the file:
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Web.UI.WebControls;
3. Change the namespace declaration from Wrox.Lists.FieldTypes.SSN to Wrox.Lists
.FieldTypes
to remove the SSN reference
4. Change the class denition to be public and to inherit from TextField:
public class SSNFieldControl : TextField
5. Override the DisplayTemplateName property with the following implementation:
public override string DisplayTemplateName
{
get
{
return “SSNDisplay”;
}
set
{
base.DisplayTemplateName = value;
}
}
The DisplayTemplateName property returns the ID of the rendering template responsible for render-
ing the display form. This is the ID value (
SSNDisplay) specified in step 5 of the previous section.
6. Override the DefaultTemplateName property ...