DeviceSpecificChoiceCollection Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Caution
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.
Represents a collection of choices for the DeviceSpecific class. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.
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
- Inheritance
- Attributes
Examples
The following code example shows how to use the DeviceSpecificChoiceCollection class to gain access to the choices in a DeviceSpecific/Choice construct. For your convenience, a Web.config file containing the filters follows the example code.
Note
The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information, see ASP.NET Web Forms Page Code Model.
<%@ 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>
Remarks
Accessing the Choices property of a DeviceSpecific object retrieves a DeviceSpecificChoiceCollection object. This collection implements the ICollection interface (through the ArrayListCollectionBase object); it implements all properties and methods of the ICollection interface.
Properties
All |
Retrieves an array of DeviceSpecificChoice objects from the collection. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
Count |
Returns the number of elements in a collection. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. (Inherited from ArrayListCollectionBase) |
IsReadOnly |
Gets a value indicating whether a collection is read-only. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. (Inherited from ArrayListCollectionBase) |
IsSynchronized |
Gets a value indicating whether a collection is synchronized. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. (Inherited from ArrayListCollectionBase) |
Item[Int32] |
Returns a DeviceSpecificChoice item in the collection, by index. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
Items |
Gets or sets the collection of items in an array list object. The default value is Empty. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. (Inherited from ArrayListCollectionBase) |
SyncRoot |
Returns the SyncRoot object for the collection. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. (Inherited from ArrayListCollectionBase) |
Methods
Add(DeviceSpecificChoice) |
Adds a DeviceSpecificChoice object to the end of a collection. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
AddAt(Int32, DeviceSpecificChoice) |
Adds a choice at the location in the collection specified by the |
Clear() |
Clears the collection. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
CopyTo(Array, Int32) |
Copies the items in the collection to an array, starting at the given index. Intended for internal use only. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. (Inherited from ArrayListCollectionBase) |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetEnumerator() |
Retrieves an enumerator for the collection. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. (Inherited from ArrayListCollectionBase) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
Remove(DeviceSpecificChoice) |
Removes the specified choice. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
RemoveAt(Int32) |
Removes the item at the specified index. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET. |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
Extension Methods
Cast<TResult>(IEnumerable) |
Casts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
Filters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
Enables parallelization of a query. |
AsQueryable(IEnumerable) |
Converts an IEnumerable to an IQueryable. |