移动 .NET 事件
** Mobile Controls exposes device independent programmable events. **
事件编程
移动控件有一个可对属性,方法和事件编程的对象模型。
要得到完整的信息请参考“参考部分”。
提交文本
这个页面有两个表单:
1@ Page
2
3Inherits=
4
5"System.Web.UI.MobileControls.MobilePage"
1@ Register
2
3TagPrefix="Mobile"
4
5Namespace="System.Web.UI.MobileControls"
6
7Assembly="System.Web.Mobile"
1<script runat="server">
2
3Dim age
4
5Sub AgeClick(sender As Object, e As EventArgs)
6
7age=text1.Text
8
9ActiveForm=Form2
10
11End Sub
12
13Sub Form2_Activate(sender As Object,e As EventArgs)
14
15message.Text="You are " & age & " years old"
16
17End Sub
18
19</script>
< Mobile :Form id="form1" runat="server">
< Mobile :Label runat="server">Age? < Mobile :TextBox runat="server" id="text1" />
< Mobile :Command runat="server" OnClick="AgeClick" Text="Submit" />
< Mobile :Form id="form2" runat="server" OnActivate="Form2_Activate">
< Mobile :Label runat="server" id="message" />
当一个页面有两个表单的时候,第一个表单总是作为打开的默认表单。
第一个表单有一内容是 Age 的 label 控件,一个输入控件用来输入年龄 (Age) 以及一个提交( Submit )按钮。
第二个页面通过第一个页面的提交按钮激活(译者注:偶觉的是第二个 Form 通过第一个 Form 的提交按钮激活,而不是原文种的 Page 。),同时显示相应信息。
当应用程序运行在移动设备上的时候,这两个页面看起来就像下面:
Form1:
Age?
Form 2
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
需要了解更多的控件参考,包括属性方法,事件和更多的例子,请参考 ”Mobile Reference” 页面。