|
一个简单的例子 让我们写一个简单应用程序,显示一个文本框接受输入并在下一个窗体中显示。 〈%@ Page Inherits="System.Mobile.UI.MobilePage" %〉 〈%@ Register TagPrefix="mobile" Namespace="System.Mobile.UI" %〉 〈Script language="VB" runat="server"〉
Sub Btn_OnClick(Src As Object, E As EventArgs) ‘move to the next mobile form
ActiveForm = frm2 ‘display the name.
EnteredName.Text = "Your name is: " & YourName.Text End Sub 〈/Script〉 〈mobile:Form id="frm1" runat=server〉 〈mobile:Label runat=server〉Your Name:〈/mobile:Label〉 〈mobile:TextBox runat="server" id="YourName" /〉 〈mobile:Command runat="server" id="btn" OnClick="Btn_OnClick"〉Ok 〈/mobile:Form〉 〈mobile:Form id="frm2" runat=server〉
〈mobile:Label runat="server" id="EnteredName" /〉 〈/mobile:Form〉 在以上的代码中,创建了两个窗体。第一个窗体的id为frm1, 第一个窗体的idfrm2。之所以使用这个方法是因为Mobile Form控件不支持name属性,而支持id属性。ASP.NET运行时就是通过这样的方法来确认窗体的。在第一个窗体中,添加了一个lable控件,一个textbox控件和一个button控件。当点击button时,服务器端的VB子程序(Btn_OnClick)就被调用。这对于那些熟悉VB的人来说就象在家里一样亲切。在处理VB子程序的事件里,通过给frm2设置ActiveForm方法来跳到下一个窗体。然后访问定义在frm2中lable控件并设置用户提交的值。 (出处:www.yesky.com) |