Share via


DeviceSpecificChoiceCollection Class

Holds a set of choices for the DeviceSpecific class.

public class System.Web.UI.MobileControls.DeviceSpecificChoiceCollection
   : System.Web.UI.MobileControls.ArrayListCollectionBase

Remarks

Accessing the Choices property of a DeviceSpecific object retrieves a DeviceSpecificChoiceCollection object. This collection implements from the System.Collections.ICollection object (through the ArrayListCollectionBase object); it implements all properties and methods of the ICollection interface.

Example

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 follows the example code.

<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" 
  Language="c#" Debug="true"%>

<script language="c#" runat="server">

public void Page_Load(Object sender, EventArgs e)
{
  // Cycle through the DeviceSpecificChoiceCollection.
  for (int i=0; i<Panel1.DeviceSpecific.Choices.Count; i++)
  {
    Label1.Text = "Panel has "+ 
      Panel1.DeviceSpecific.Choices[i].Templates.Count.ToString() + 
      " Templates.";

    Label2.Text = "Filter name is " + 
      Panel1.DeviceSpecific.Choices[i].Filter.ToString() + 
      ".";
  }
}
</script>

<mobile:Form runat="server" id=frmChoice >
  <mobile:panel runat="server" id=Panel1 Font-Italic=false 
    ForeColor="blue">    
    <DeviceSpecific> 
      <Choice Filter="isHTML32">
        <HeaderTemplate>
        </HeaderTemplate>
        <FooterTemplate>
        </FooterTemplate>
        <ContentTemplate>
          <br/>
          <mobile:Label id="Label3" runat="server" 
            Text="Visible in an HTML Browser" />
          <br/>
        </ContentTemplate>
      </Choice>
      <Choice Filter="isWML11">
        <HeaderTemplate>
        </HeaderTemplate>
        <ContentTemplate>
          <br/>
          <mobile:Label id="Label4" runat="server" 
            Text="Viewable in a WML browser" />
          <br/>
        </ContentTemplate>
      </Choice>
    </DeviceSpecific>
  </mobile:panel>
  <mobile:Label id="Label1" runat="server" Font-Bold="true" />
  <mobile:Label id="Label2" runat="server" Font-Bold="true" />
</mobile:Form>

Place the following web.config file in the same folder as the .aspx file to run the aspx file.

<configuration>
   <system.web>
   <deviceFilters>
      <filter name="isHTML32" compare="PreferredRenderingType" argument="html32" />
      <filter name="prefersWBMP" compare="PreferredImageMime" argument="image/vnd.wap.wbmp" />
      <filter name="IsMME" compare="type" argument="Microsoft Mobile Explorer" />
      <filter name="IsR380" compare="type" argument="Ericsson R380" />
      <filter name="isWML11" compare="PreferredRenderingType" argument="wml11" />
      <filter name="IsGoA" compare="Browser" argument="Go.Web" />
   </deviceFilters>
   </system.web>
</configuration>

Requirements

Namespace: System.Mobile.Web.UI.MobileControls

Assembly: System.Web.Mobile

See Also

DeviceSpecificChoice Class