Implementing Templated Rendering
ASP.NET mobile controls that support templated rendering also support a default rendering. Decisions on how templates are used to put together rendering can vary depending on the target device. ASP.NET provides a standard sequence of operations that allow templated rendering to be device-specific. Mobile controls that support templated rendering must use the following sequence:
Do not call CreateTemplatedUI if the control is not templated.
The default implementation of the control adapter's CreateTemplatedUI method, which is defined in the control adapter base class, in turn calls the control's CreateDefaultTemplatedUI method. You can code controls that override this method to implement general templated rendering.
In the adapter's Render method, the control renders templates by rendering the control's child (where instances of templates are created).
Mobile controls also must always create instances of new templates inside a container control type derived from TemplateContainer. This is a stricter rule than the rule for ASP.NET server controls, which requires only that the control implement the INamingContainer marker interface. The following code example shows how to create an instance of a template in a mobile control.
With templated rendering, the ItemCommand event handler is called through the ASP.NET event-bubbling mechanism. The event handler is passed a parameter that points to the source item and to the CommandName property of the control that generated the event. This allows you to render a single list item with multiple associated interactions.
On default rendering, the control provides a simple user interface that allows the user to click a list of items. On postback, the control calls the ItemCommand handler with an argument pointing to the source item. The CommandName property returns a null.