Condividi tramite


Classe DeviceSpecificChoiceCollection

Contiene un insieme di opzioni per la classe DeviceSpecific.

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

Osservazioni

L'accesso alla proprietà Choices di un oggetto DeviceSpecific restituisce un oggetto DeviceSpecificChoiceCollection. Questo insieme consente di eseguire implementazioni a partire dall'oggetto System.Collections.ICollection (mediante l'oggetto ArrayListCollectionBase); è possibile implementare tutte le proprietà e i metodi dell'interfaccia ICollection.

Esempio

Nel codice di esempio riportato di seguito viene indicato come utilizzare la classe DeviceSpecificChoiceCollection per accedere alle opzioni contenute in un costrutto DeviceSpecific/Choice. Per praticità dell'utente, il codice di esempio è seguito da un file Web.config.

<%@ 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>

Inserire il seguente file Web.config nella stessa cartella in cui è contenuto il file ASPX per eseguirlo.

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

Requisiti

Spazio dei nomi: System.Mobile.Web.UI.MobileControls

Assembly: System.Web.Mobile

Vedere anche

Classe DeviceSpecificChoice