Condividi tramite


TemplateBasedControl.TemplateName Property

Gets or sets the name of the control's rendering template.

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
Public Property TemplateName As String
    Get
    Set
'Usage
Dim instance As TemplateBasedControl
Dim value As String

value = instance.TemplateName

instance.TemplateName = value
public string TemplateName { get; set; }

Property Value

Type: System.String
A String object that represents the name of a rendering template that renders the control. The default is a null reference (Nothing in Visual Basic).

Remarks

The TemplateName property returns the value of the DefaultTemplateName property unless a specific value has been set for the TemplateName property.

Notes to Callers

Typically, calling code should set the TemplateName property to 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\14\template\controltemplates

The ID attribute identifies the RenderingTemplate object that renders the control.

If you want to render the control differently in certain contexts, such as on particular forms, you can designate an alternative template by using the AlternateTemplateName property. Avoid using the DefaultTemplateName property for this purpose; this will enhance your code's readability and its consistency with other classes that are derived from the TemplateBasedControl class.

See Also

Reference

TemplateBasedControl Class

TemplateBasedControl Members

Microsoft.SharePoint.WebControls Namespace

Other Resources

How to: Create a Custom Field Type

Custom Field Types

Walkthrough: Creating a Custom Field Type