Partager via


TemplateBasedControl.DefaultTemplateName property

Gets the name of the default rendering template.

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

Syntax

'Declaration
Protected Overridable ReadOnly Property DefaultTemplateName As String
    Get
'Usage
Dim value As String

value = Me.DefaultTemplateName
protected virtual string DefaultTemplateName { get; }

Property value

Type: System.String
A String object that names a rendering template.

Remarks

Notes to inheritors

The default implementation always returns a null reference (Nothing in Visual Basic).

In typical derived classes, the DefaultTemplateName property contains the value of the ID attribute of a <RenderingTemplate> element in an .ascx file that is located in the following folder:

%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\15\template\controltemplates

The ID attribute identifies the RenderingTemplate object that can be used as a fallback template if the TemplateName property has not been set or, if for any reason, the template it names cannot be used.

For readability and consistency with other classes that are derived from the TemplateBasedControl class, avoid using the DefaultTemplateName property to identify a template that you want to use in special contexts, such as on particular forms. Instead, use the AlternateTemplateName property.

Examples

The following is an example of an override of the DefaultTemplateName property. For the full example, see Walkthrough: Creating a Custom Field Type.

protected override string DefaultTemplateName
{
    get
    {
        return "ISBNFieldControl";
    }
}
Protected Overrides ReadOnly Property DefaultTemplateName() As String
    Get
        Return "ISBNFieldControl"
    End Get
End Property

See also

Reference

TemplateBasedControl class

TemplateBasedControl members

Microsoft.SharePoint.WebControls namespace

Other resources

Patterns of Custom Field Rendering

Custom Field Types

Walkthrough: Creating a Custom Field Type