ASP.Net/Mobile Control/SelectionList
Содержание
Bind data to mobile selectionlist (VB.net)
<source lang="csharp">
<%@ Page
Inherits="System.Web.UI.MobileControls.MobilePage" Language="VB" Debug=True
%> <%@ Register
TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile"
%> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OLEDB" %> <script runat="server" language="VB"> Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
If Not IsPostBack Then Dim DBConn as OleDbConnection Dim DBCommand As OleDbDataAdapter Dim DSPageData as New DataSet DBConn = New OleDbConnection( _ "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _ & "DATA SOURCE=" _ & Server.MapPath("EmployeeDatabase.mdb;")) DBCommand = New OleDbDataAdapter _ ("Select FirstName " _ & "From Employee " _ & "Order By FirstName", DBConn) DBCommand.Fill(DSPageData, _ "Employee") sl1.DataSource = _ DSPageData.Tables("Employee").DefaultView sl1.DataBind() End If
End Sub Sub OK_OnSubmit(Sender As Object, E As EventArgs)
ActiveForm = FinishForm lbl1.Text = "You selected " _ & sl1.Selection.ToString()
End Sub </script> <mobile:Form id="StartForm" runat="server"> <mobile:selectionlist
runat="server" id="sl1" selecttype="DropDown" datatextfield="FirstName"
/> <mobile:Command
runat="server" id="cmdOK" OnClick="OK_OnSubmit" Text="OK"
/> </mobile:form> <mobile:form
id="FinishForm" runat="server">
<mobile:label
runat="server" id="lbl1"
/> </mobile:form>
</source>
<A href="http://www.nfex.ru/Code/ASPDownload/EmployeeDatabase.zip">EmployeeDatabase.zip( 10 k)</a>
mobile selectionList Demo (ComboBox) (VB.net)
<source lang="csharp">
<%@ Page
Inherits="System.Web.UI.MobileControls.MobilePage" Language="VB"
%> <%@ Register
TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile"
%> <script runat="server" language="VB"> Sub OK_OnSubmit(Sender As Object, E As EventArgs)
lbl1.Text = sl1.Selection.Value ActiveForm = Test2
End Sub </script> <mobile:Form id="Test" runat="server">
<mobile:Label runat="server" id="lblTitle" StyleReference="title" Text="SelectionList Test Page" /> <mobile:SelectionList runat="server" id="sl1" SelectType="DropDown" > <Item Text="Item1" Value="1:1" /> <Item Text="Item2" Value="1:2" /> </mobile:SelectionList> <mobile:Command runat="server" id="cmdOK" OnClick="OK_OnSubmit" Text="OK" />
</mobile:Form> <mobile:Form id="Test2" runat="server">
<mobile:Label runat="server" id="lblTitle2" StyleReference="title" Text="SelectionList Test Page" /> <mobile:Label runat="server" id="lbl1" />
</mobile:Form>
</source>
mobile:SelectionList (VB.net)
<source lang="csharp">
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="vb" %> <HEAD>
<title>Mobile Control Example</title> <script runat="server"> Protected Sub List1_Click(source As Object, e As ListCommandEventArgs) Select Case e.ListItem.Value Case 2 ActiveForm = Form2 Case 3 ActiveForm = Form3 Case 4 ActiveForm = Form4 End Select End Sub Protected Sub Command1_Click(source As Object, e As EventArgs) If Not SelectionList1.Selection.Value = "4" Then Label1.Text = "You run as Admin too often!" Else Label1.Text = "Excellent!" End If End Sub
</script> </HEAD> <body xmlns:mobile="http://schemas.microsoft.ru/Mobile/WebForm">
Mobile Control Example
<mobile:Form id="Form1" Runat="server"> <mobile:Label id="Label2" runat="server">Choose a sample:</mobile:Label> <mobile:List id="List1" OnItemCommand="List1_Click" runat="server" Decoration="Numbered"> <Item Value="2" Text="SelectionList Sample"></Item> <Item Value="3" Text="PhoneCall Sample"></Item> <Item Value="4" Text="TextView Sample"></Item> </mobile:List> </mobile:Form> <mobile:Form id="Form2" runat="server"> <mobile:Label id="Label1" runat="server">How often do you run Windows as Admin?</mobile:Label> <mobile:SelectionList id="SelectionList1" runat="server"> <Item Value="0" Text="Always"></Item> <Item Value="1" Text="Often"></Item> <Item Value="2" Text="Sometimes"></Item> <Item Value="3" Text="Rarely"></Item> <Item Value="4" Text="Never"></Item> </mobile:SelectionList> <mobile:Command id="Command1" OnClick="Command1_Click" runat="server">Submit</mobile:Command> </mobile:Form> <mobile:Form id="Form3" runat="server"> <mobile:PhoneCall id="PhoneCall1" runat="server" PhoneNumber="(000)555-1234" AlternateUrl="http://www.nfex.ru">Call Mom</mobile:PhoneCall> </mobile:Form> <mobile:Form id="Form4" runat="server"> <mobile:TextView id="TextView1" runat="server" Wrapping="Wrap">mobile text view</mobile:TextView> </mobile:Form>
</body>
</source>
Set selected item in a mobile selectionlist (VB.net)
<source lang="csharp">
<%@ Page
Inherits="System.Web.UI.MobileControls.MobilePage" Language="VB"
%> <%@ Register
TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile"
%> <script runat="server" language="VB"> </script> <mobile:Form id="Test" runat="server"> <mobile:selectionlist
runat="server" id="sl1" selecttype="Radio"
>
<item selected text="A"/> <item text="B"/> <item text="C"/>
</mobile:selectionlist> </mobile:form>
</source>