DeviceSpecificChoiceCollection クラス
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)
構文
DeviceSpecific オブジェクトの Choices プロパティにアクセスすると、DeviceSpecificChoiceCollection オブジェクトを取得できます。このコレクションは、ICollection インターフェイスを (ArrayListCollectionBase オブジェクトを使用して) 実装します。実装されるのは、ICollection インターフェイスのすべてのプロパティとメソッドです。
DeviceSpecificChoiceCollection クラスを使用して、DeviceSpecific/Choice 構成要素の選択項目にアクセスする方法を次のコード例にコード例示します。参考のため、フィルタを格納している Web.config ファイルをコード例の後に記載しています。
メモ |
---|
次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルは、拡張子が .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 > <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> <br /><span space="preserve">...</span><br /><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>
System.Web.UI.MobileControls.ArrayListCollectionBase
System.Web.UI.MobileControls.DeviceSpecificChoiceCollection
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- DeviceSpecificChoiceCollection クラスのページへのリンク