DeviceSpecificChoiceCollection Class

Represents a collection of choices for the DeviceSpecific class.

Namespace: System.Web.UI.MobileControls
Assembly: System.Web.Mobile (in

public class DeviceSpecificChoiceCollection : ArrayListCollectionBase
public class DeviceSpecificChoiceCollection extends ArrayListCollectionBase
public class DeviceSpecificChoiceCollection extends ArrayListCollectionBase

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.


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" 
    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, _
            Label2.Text &= String.Format(txt2, _
    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"
        CType(form1, IParserAccessor).AddParsedSubObject(devSpecific)
    End Sub

<html xmlns="" >
    <mobile:form id="form1" runat="server">
        <mobile:Panel id="Panel1" Runat="server">
            <mobile:DeviceSpecific ID="DeviceSpecific1" Runat="server">
                <Choice Filter="isHTML32">
                        <!-- For HTML Browsers -->
                        <br />
                        <mobile:Label ID="Label3" Runat="server" 
                            Text="Visible in an HTML Browser" />
                        <br />
                <Choice Filter="isWML11">
                        <!-- For WML Browsers -->
                        <br />
                        <mobile:Label ID="Label4" Runat="server" 
                            Text="Viewable in a WML browser" />
                        <br />
        <mobile:Label id="Label1" Runat="server" Font-Bold="true" />
        <mobile:Label ID="Label2" Runat="server" Font-Bold="true" />
      <compilation debug="true" strict="false" explicit="true" />
      <authentication mode="Windows" />
                <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" />

      <!-- Add the device filters used in the example -->
          <filter name="isHTML32" 
                  argument="html32" />
          <filter name="isWML11" 
                  argument="wml11" />
          <filter name="isCHTML10" 
                  argument="chtml10" />


  • 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.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 2.0, 1.1

Community Additions