DeviceSpecificChoiceCollection (Clase)
Ensamblado: System.Web.Mobile (en system.web.mobile.dll)
Al tener acceso a la propiedad Choices de un objeto DeviceSpecific, se recupera un objeto DeviceSpecificChoiceCollection. Esta colección implementa la interfaz ICollection (a través del objeto ArrayListCollectionBase); implementa todas las propiedades y métodos de la interfaz ICollection.
En el ejemplo de código siguiente se muestra cómo utilizar la clase DeviceSpecificChoiceCollection para obtener acceso a las opciones de una construcción DeviceSpecific/Choice. Para su comodidad, después del código de ejemplo se incluye un archivo web.config que contiene los filtros.
Nota: |
|---|
| El siguiente ejemplo de código utiliza el modelo de código de un solo archivo y puede que no funcione correctamente si se copia directamente en un archivo de código subyacente. Se debe copiar este código de ejemplo en un archivo de texto vacío con una extensión .aspx. Para obtener más información, vea Modelo de código de las páginas Web ASP.NET. |
<%@ Page Language="C#" 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"> public void Page_Load(Object sender, EventArgs e) { int count = this.Panel1.DeviceSpecific.Choices.Count; // Cycle through the DeviceSpecificChoiceCollection. for (int i = 0; i < count; i++) { string txt1 = "Choice {0} has {1} Templates. "; string txt2 = "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); } } // Add a DeviceSpecificChoice section programatically protected void form1_Init(object sender, EventArgs e) { DeviceSpecific devSpecific = Panel1.DeviceSpecific; DeviceSpecificChoice devChoiceHtml = new DeviceSpecificChoice(); devChoiceHtml.Filter = "isCHTML10"; devSpecific.Choices.Add(devChoiceHtml); ((IParserAccessor)form1).AddParsedSubObject(devSpecific); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <body> <mobile:Form ID="form1" Runat="server" OnInit="form1_Init"> <mobile:Panel id="Panel1" Runat="server"> <mobile:DeviceSpecific 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" /> <authentication mode="Windows" /> <customErrors mode="Off" /> <httpRuntime useFullyQualifiedRedirectUrl="true" /> <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 para trabajar en un entorno alojado en host. Valor de petición: LinkDemand; valor de permiso: Minimal.
- AspNetHostingPermission para trabajar en un entorno alojado en host. Valor de petición: InheritanceDemand; valor de permiso: Minimal.
System.Web.UI.MobileControls.ArrayListCollectionBase
System.Web.UI.MobileControls.DeviceSpecificChoiceCollection
Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter
Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.
Nota: