移动设备的Web应用程序开发—-(事件和输入)

移动.NET事件
Mobile Controls exposes device independent programmable events.



--------------------------------------------------------------------------------


事件编程
移动控件有一个可对属性,方法和事件编程的对象模型。


要得到完整的信息请参考“参考部分”。



--------------------------------------------------------------------------------


提交文本
这个页面有两个表单:


<%@ Page


Inherits=


"System.Web.UI.MobileControls.MobilePage"%>


<%@ Register


TagPrefix="Mobile"


Namespace="System.Web.UI.MobileControls"


Assembly="System.Web.Mobile" %>


<script runat="server">


Dim age


 


Sub AgeClick(sender As Object, e As EventArgs)


age=text1.Text


ActiveForm=Form2


End Sub


Sub Form2_Activate(sender As Object,e As EventArgs)


  message.Text="You are " & age & " years old"


End Sub


</script>


 


<Mobile:Form id="form1" runat="server">


<Mobile:Label runat="server">Age?</Mobile:Label>


<Mobile:TextBox runat="server" id="text1" />


<Mobile:Command runat="server" OnClick="AgeClick" Text="Submit" />


</Mobile:Form>


 


<Mobile:Form id="form2" runat="server" OnActivate="Form2_Activate">


<Mobile:Label runat="server" id="message" />


</Mobile:Form>
 


当一个页面有两个表单的时候,第一个表单总是作为打开的默认表单。


第一个表单有一内容是Age的label控件,一个输入控件用来输入年龄(Age)以及一个提交(Submit)按钮。


第二个页面通过第一个页面的提交按钮激活(译者注:偶觉的是第二个Form通过第一个Form的提交按钮激活,而不是原文种的Page。),同时显示相应信息。


当应用程序运行在移动设备上的时候,这两个页面看起来就像下面:


Form1:







Age?




Form 2







You are 11 years old






You are 11 years old


 


 



 


移动.NET输入
Input Controls are used to collect input from the mobile user.



--------------------------------------------------------------------------------


输入控件
有很多的移动控件支持用户输入。


在前面章节的demo中,最长用的输入控件可能就是TextBox控件了。TextBox是完成一些简单的输入,比如像姓名,数量,以及标识符和关键字。


如果输入大量的文本那么TextView控件可能是更好的选择。TextView控件允许长的多行的输入就像你用MSN给其他人发消息一样。



--------------------------------------------------------------------------------


数字输入
我们可以通过设置TextBox的属性Numeric让TextBox只接收来接收数字的输入信息。


注意:这个特性通常工作在通过改变从文字到数字的输入模式的手机上。然而在HTML的浏览器上,通常不支持这种行为。



--------------------------------------------------------------------------------


密码输入
我们可以将TextBox控件的Password属性设置成true或者false来指定TextBox处理密码字段。


密码字段将会通过*(星号)替换原始的文本来隐藏输入信息。



--------------------------------------------------------------------------------


列表控件
TextBox和TextView控件是非常适合输入信息的,但是有时你想让用户从已有的列表中选择事先定义好的值。


SelectionList控件支持下拉列表,复选选框和单选按钮。这部分的内容将在其他的章节介绍。


List控件支持菜单和列表的选项,List控件将会在其他的章节介绍。



--------------------------------------------------------------------------------


用户界面控件
用户控件是显示用户界面的控件集。


Name
 Function
 
Command
 Performs an action
 
Form
 Defines a container for mobile controls
 
Image
 Defines an image
 
Label
 Defines a text
 
Link
 Defines a hyperlink
 
List
 Defines a list
 
MobilePage
 Defines a container for mobile controls
 
ObjectList
 Defines a list of data objects
 
Panel
 Defines a container for other controls
 
SelectionList
 Defines a list to select from
 
StyleSheet
 Defines styles to be applied to other controls
 
TextBox
 Defines a single line input box
 
TextView
 Defines a multi-line input box