How to: Create and Edit Templates
Templates are powerful tools for enhancing the appearance of ASP.NET mobile controls or customizing mobile controls for specific types of devices. Templates must be associated with specific device filters. Therefore, you must define and apply device filters to controls prior to creating control templates.
To select the device filter that the template or templates will be associated with, click Templating Options in the control's shortcut menu. The Templating Options command is available for all controls that support templates. The following table describes available templates.
Template name |
Use to ... |
---|---|
ContentTemplate |
Customize the device-specific content of a Panel control. |
HeaderTemplate |
Customize the header of a List, ObjectList, or Form control. |
FooterTemplate |
Customize the footer of a List, ObjectList, or Form control. |
ItemTemplate |
Customize all items in a List or ObjectList control. |
AlternatingItemTemplate |
Customize alternating items in a List or ObjectList control. |
SeparatorTemplate |
Customize separators that appear between items in a List or ObjectList control. |
ItemDetailsTemplate |
Customize how list item details are rendered in an ObjectList control. |
To select an applied device filter
Right-click any mobile control that supports templates, and then click Templating Options.
The Templating Options dialog box appears.
Select a filter from the Applied Device Filter list. If you want to edit templates for a device filter that is not found in the Applied Device Filter list, click the Edit button to open the Applied Device Filters dialog box.
Optionally, select or enter a markup language schema in the Markup Schema box.
Hinweis
The information specified in the Markup Schema box is used only by Visual Studio for validation and IntelliSense support in Source view. It has no effect at run time.
When you close the Templating Options dialog box, the designer sets the TemplateDeviceFilter for the control to the name of the device filter specified in the Applied Device Filter list. The selected control is now ready for template editing.
To edit a template
Right-click the control, and then click Edit Template.
The Edit Template menu contains the list of customizable templates that the currently selected control supports.
In the Edit Template menu, click the template you want to edit.
In most templates, you can type literal text directly into the template, or you can drag controls from the Toolbox and then set their properties. For example, you might do the following:
Drag a Label control into the header template. You can set header text in the control, and then configure its properties, such as the foreground color.
Drag an Image control into a separator template. You can then use the ImageUrl property to link to a Web graphic file of the separator that you want to use.
Hinweis
You can add ASP.NET Web server controls to templates intended for HTML-based devices.
When you have finished, right-click the control and then click End Template Editing.
See Also
Tasks
Reference
Applied Device Filters Dialog Box