共用方式為


DeviceSpecificChoiceCollection 類別

表示 DeviceSpecific 類別的選擇集合。

命名空間: System.Web.UI.MobileControls
組件: System.Web.Mobile (在 system.web.mobile.dll 中)

語法

'宣告
Public Class DeviceSpecificChoiceCollection
    Inherits ArrayListCollectionBase
'用途
Dim instance As DeviceSpecificChoiceCollection
public class DeviceSpecificChoiceCollection : ArrayListCollectionBase
public ref class DeviceSpecificChoiceCollection : public ArrayListCollectionBase
public class DeviceSpecificChoiceCollection extends ArrayListCollectionBase
public class DeviceSpecificChoiceCollection extends ArrayListCollectionBase

備註

存取 DeviceSpecific 物件的 Choices 屬性可擷取 DeviceSpecificChoiceCollection 物件。這個集合實作 ICollection 介面 (透過 ArrayListCollectionBase 物件),並實作 ICollection 介面的所有屬性和方法。

範例

下列程式碼範例顯示如何使用 DeviceSpecificChoiceCollection 類別,存取 DeviceSpecific/Choice 建構內的選擇。為了方便您使用,包含篩選條件的 Web.config 檔會附在範例程式碼後面。

Note注意事項

以下程式碼範例使用單一檔案程式碼模型,如果直接複製到程式碼後置 (Code-Behind) 檔案即可能無法作用。這個程式碼範例必須複製到副檔名為 .aspx 的空白文字檔。如需詳細資訊,請參閱 ASP.NET Web 網頁程式碼模型

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

.NET Framework 安全性

繼承階層架構

System.Object
   System.Web.UI.MobileControls.ArrayListCollectionBase
    System.Web.UI.MobileControls.DeviceSpecificChoiceCollection

執行緒安全

這個型別的所有公用靜態成員 (即 Visual Basic 中的 Shared 成員) 都是安全執行緒。並非所有的執行個體成員均為安全執行緒。

平台

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

.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。

版本資訊

.NET Framework

支援版本:2.0、1.1

請參閱

參考

DeviceSpecificChoiceCollection 成員
System.Web.UI.MobileControls 命名空間
DeviceSpecificChoice 類別

其他資源

DeviceSpecific 控制項簡介
<DeviceSpecific> 項目
<Choice> 項目 (.NET Framework 開發人員手冊)