DeviceSpecificChoiceCollection Class
Assembly: System.Web.Mobile (in system.web.mobile.dll)
Accessing the Choices property of a DeviceSpecific object retrieves a DeviceSpecificChoiceCollection object. This collection implements the ICollection interface (through the ArrayListCollectionBase object); it implements all properties and methods of the ICollection interface.
The following code example shows how to use the DeviceSpecificChoiceCollection class to gain access to the choices in a DeviceSpecific/Choice construct. For your convenience, a Web.config file containing the filters follows the example code.
Note |
|---|
| The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information, see ASP.NET Web Page Code Model. |
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <%@ Import Namespace="System.Web.Mobile" %> <script runat="server"> Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim count As Integer = Panel1.DeviceSpecific.Choices.Count Dim i As Integer ' Cycle through the DeviceSpecificChoiceCollection. For i = 0 To count - 1 Dim txt1 As String = "Choice {0} has {1} Templates. " Dim txt2 As String = "Filter name is '{0}'. " Label1.Text &= String.Format(txt1, i, _ Panel1.DeviceSpecific.Choices(i).Templates.Count) Label2.Text &= String.Format(txt2, _ Panel1.DeviceSpecific.Choices(i).Filter) Next End Sub ' Add a DeviceSpecificChoice section programatically Protected Sub form1_Init(ByVal sender As Object, ByVal e As EventArgs) Dim devSpecific As DeviceSpecific = Panel1.DeviceSpecific Dim devChoiceHtml As DeviceSpecificChoice = New DeviceSpecificChoice() devChoiceHtml.Filter = "isCHTML10" devSpecific.Choices.Add(devChoiceHtml) CType(form1, IParserAccessor).AddParsedSubObject(devSpecific) End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <body> <mobile:form id="form1" runat="server"> <mobile:Panel id="Panel1" Runat="server"> <mobile:DeviceSpecific ID="DeviceSpecific1" Runat="server"> <Choice Filter="isHTML32"> <ContentTemplate> <!-- For HTML Browsers --> <br /> <mobile:Label ID="Label3" Runat="server" Text="Visible in an HTML Browser" /> <br /> </ContentTemplate> </Choice> <Choice Filter="isWML11"> <ContentTemplate> <!-- For WML Browsers --> <br /> <mobile:Label ID="Label4" Runat="server" Text="Viewable in a WML browser" /> <br /> </ContentTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Panel> <mobile:Label id="Label1" Runat="server" Font-Bold="true" /> <mobile:Label ID="Label2" Runat="server" Font-Bold="true" /> </mobile:form> </body> </html> ...<configuration> <system.web> <compilation debug="true" strict="false" explicit="true" /> <authentication mode="Windows" /> <pages> <namespaces> <clear /> <add namespace="System" /> <add namespace="System.Collections" /> <add namespace="System.Web" /> <add namespace="System.Web.UI" /> <add namespace="System.Web.UI.WebControls" /> <add namespace="System.Web.UI.HtmlControls" /> </namespaces> </pages> <!-- Add the device filters used in the example --> <deviceFilters> <filter name="isHTML32" compare="PreferredRenderingType" argument="html32" /> <filter name="isWML11" compare="PreferredRenderingType" argument="wml11" /> <filter name="isCHTML10" compare="PreferredRenderingType" argument="chtml10" /> </deviceFilters> </system.web> </configuration>
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System.Web.UI.MobileControls.ArrayListCollectionBase
System.Web.UI.MobileControls.DeviceSpecificChoiceCollection
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Note