DeviceSpecificChoiceCollection 類別

定義

警告

The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.

表示 DeviceSpecific 類別的選擇集合。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

public ref class DeviceSpecificChoiceCollection : System::Web::UI::MobileControls::ArrayListCollectionBase
public class DeviceSpecificChoiceCollection : System.Web.UI.MobileControls.ArrayListCollectionBase
[System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
public class DeviceSpecificChoiceCollection : System.Web.UI.MobileControls.ArrayListCollectionBase
type DeviceSpecificChoiceCollection = class
    inherit ArrayListCollectionBase
[<System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")>]
type DeviceSpecificChoiceCollection = class
    inherit ArrayListCollectionBase
Public Class DeviceSpecificChoiceCollection
Inherits ArrayListCollectionBase
繼承
DeviceSpecificChoiceCollection
屬性

範例

下列程式代碼範例示範如何使用 DeviceSpecificChoiceCollection 類別來存取 DeviceSpecific/Choice 建構中的選項。 為了方便起見,包含篩選條件的 Web.config 檔案遵循範例程序代碼。

注意

下列程式代碼範例會使用單一檔案程式代碼模型,如果直接複製到程式代碼後置檔案,可能無法正常運作。 此程式代碼範例必須複製到擴展名為 .aspx 的空白文字檔中。 如需詳細資訊,請參閱 ASP.NET Web Forms 頁碼模型

<%@ 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);
        }
    }

    //<Snippet3>
    // 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);
    }
    //</Snippet3>
</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>
<%@ 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
    
    '<Snippet3>
    ' 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
    '</Snippet3>
</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>

備註

存取 Choices 物件的 屬性 DeviceSpecificDeviceSpecificChoiceCollection 擷取 物件。 這個集合會 ICollection 透過 ArrayListCollectionBase 物件) 實作介面 (;它會實作介面的所有屬性和方法 ICollection

屬性

All
已淘汰.

從集合擷取 DeviceSpecificChoice 物件的陣列。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

Count
已淘汰.

傳回集合中的項目數。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

(繼承來源 ArrayListCollectionBase)
IsReadOnly
已淘汰.

取得值,指出集合是否為唯讀。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

(繼承來源 ArrayListCollectionBase)
IsSynchronized
已淘汰.

取得值,指出是否同步處理集合。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

(繼承來源 ArrayListCollectionBase)
Item[Int32]
已淘汰.

依索引傳回集合中的 DeviceSpecificChoice 項目。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

Items
已淘汰.

取得或設定陣列清單物件中的項目集合。 預設值是 Empty。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

(繼承來源 ArrayListCollectionBase)
SyncRoot
已淘汰.

傳回集合的 SyncRoot 物件。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

(繼承來源 ArrayListCollectionBase)

方法

Add(DeviceSpecificChoice)
已淘汰.

DeviceSpecificChoice 物件加入至集合的結尾。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

AddAt(Int32, DeviceSpecificChoice)
已淘汰.

index 參數指定之集合中的位置加入選擇。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

Clear()
已淘汰.

清除集合。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

CopyTo(Array, Int32)
已淘汰.

將集合中的項目複製到從指定索引開頭的陣列。 僅供內部使用。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

(繼承來源 ArrayListCollectionBase)
Equals(Object)
已淘汰.

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()
已淘汰.

擷取集合的列舉值。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

(繼承來源 ArrayListCollectionBase)
GetHashCode()
已淘汰.

做為預設雜湊函式。

(繼承來源 Object)
GetType()
已淘汰.

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()
已淘汰.

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(DeviceSpecificChoice)
已淘汰.

移除指定的選擇。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

RemoveAt(Int32)
已淘汰.

移除指定之索引處的項目。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

ToString()
已淘汰.

傳回代表目前物件的字串。

(繼承來源 Object)

擴充方法

Cast<TResult>(IEnumerable)
已淘汰.

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)
已淘汰.

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)
已淘汰.

啟用查詢的平行化作業。

AsQueryable(IEnumerable)
已淘汰.

IEnumerable 轉換成 IQueryable

適用於

另請參閱