EnsureTemplatedUI Method (Common)
Use this method to ensure that the templates are instantiated to allow programmatic access to the instantiated contents of a template.
public virtual void EnsureTemplatedUI()
Remarks
This method is overridden by the List and ObjectList classes.
public override void EnsureTemplatedUI()
Example
The following example demonstrates how to use the EnsureTemplatedUI method to access the contents of the Label1 control within details view of the ObjectList.
Sub OnCmdClick(sender As Object, e As EventArgs)
ObjectList1.EnsureTemplatedUI()
ObjectList1.ViewMode = ObjectListViewMode.Details
CType(ObjectList1.Details.FindControl("Label1"), System.Web.UI.MobileControls.Label).Text = "New Tasks"
End Sub
<Mobile:Form id="WelcomeForm" runat="server">
<mobile:objectList id="ObjectList1" runat="server" CommandStyle-
StyleReference="subcommand" LabelStyle-StyleReference="title">
<DeviceSpecific>
<Choice>
<ItemDetailsTemplate>
<mobile:label id="Label1" runat="server" Text="Task List"
Font-Bold="true"></mobile:label>
<mobile:Command id="Command1" runat="server"
OnClick="OnCmdClick">Command</mobile:Command>
</ItemDetailsTemplate>
</Choice>
</DeviceSpecific>
</mobile:objectList>
</Mobile:Form>
[C#]
void OnCmdClick(object sender, EventArgs e)
{
ObjectList1.EnsureTemplatedUI();
ObjectList1.ViewMode = ObjectListViewMode.Details;
((Label)ObjectList1.Details.FindControl("Label1")).Text = "New Tasks";
}
<Mobile:Form id="WelcomeForm" runat="server">
<mobile:objectList id="ObjectList1" runat="server" CommandStyle-
StyleReference="subcommand" LabelStyle-StyleReference="title">
<DeviceSpecific>
<Choice>
<ItemDetailsTemplate>
<mobile:label id="Label1" runat="server" Text="Task List"
Font-Bold="true"></mobile:label>
<mobile:Command id="Command1" runat="server"
OnClick="OnCmdClick">Command</mobile:Command>
</ItemDetailsTemplate>
</Choice>
</DeviceSpecific>
</mobile:objectList>
</Mobile:Form>
See Also
Applies to: List Class | MobileControl Class | ObjectList Class