再在Designer中,双击显示Form1按钮。鼠标就会被置到Public Sub Command2_Click。加入如下代码:
Private Sub Command2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Command2.Click
Dim dateval As Date
dateval = Calendar1.SelectedDate
ActiveForm = Form1()
TextBox1.Text = dateval
End Sub
=====================
Running the TwoFormsApp Application
1,在Solution Explorer中,右击MobileWebForms1.aspx文件,然后选择Set As Start Page。
2,保存项目,然后键F5调试程序。
3,当项目运行时,在Text Filed中键入日期,然后点击显示Form1按钮,Form2就被显示了,其中有个日历控件。
4,选择一个不同的日期,然后点击显示Form2按钮。
要用可移动设备测试这个项目,你需要一个静态IP地址。
==========================
The Microsoft Mobile Internet Toolkit and a Command Line
Visual Studio.NET Beta 2把Mobile Internet Toolkit直接集成到了开发环境中去了。然而写mobile application也可以手工用你最喜欢的编辑器,Mobile Internet Toolkit和一个命令行编译器。
=============
Creating NameApp
1,创建一个目录C:\Inetpub\wwwroot\Name。
2,在Internet Services Manager,打开Default Web Site,右击一个子虚拟目录,然后点击属性。
3,在Application Settings中,点击创建按钮。
在下面的例子中,你将要在Name目录下创建两个文件。
Name.aspx是页面设计文件,里面包含了许多服务器端mobile控件。所用语言TML3.2,cHTML,WML1.1,根据客户端而定。
Name.cs是代码文件,使用C#语言写的。
=======================
Creating the Name.aspx Mobile Web Form
<%@ Page Codebehind="Name.cs" Inherits="NameApp.NamePage" Language="C#" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<mobile:Form runat="server">
<mobile:Label runat="server">What is your name?</mobile:Label>
<mobile:Textbox runat="server" id="NameEdit"/>
<mobile:Command runat="server" OnClick="GoCommand_OnClick" Text="Go!"/>
</mobile:Form >
<mobile:Form runat="server" id="SecondForm" OnActivate="SecondForm_OnActivate">
<mobile:Label runat="server" id="Greeting"/>
</mobile:Form>
创建Name.cs文件
using System;
using System.Web.UI.MobileControls;
namespace NameApp
{
public class NamePage : MobilePage
{
protected Form SecondForm;
protected TextBox NameEdit;
protected UI.Label Greeting;
private String greetingText;
protected void GoCommand_OnClick(Object sender, EventArgs e)
{
greetingText = "Hello, " + NameEdit.Text + "!";
ActiveForm = SecondForm;
}
protected void SecondForm_OnActivate(Object sender, EventArgs e)
{
Greeting.Text = greetingText;
}
}
}
=================
Compiling the Name.cs File
1,在Name目录下创建一个叫bin的文件夹。
2,在命令行中键入以下命令来编译Name.cs文件。
C:\Inetpub\wwwroot\Name> csc /r:System.Web.dll /r:System.Web.Mobile.dll _
/target:library /out:bin\NameApp.dll Name.cs
用IE 5.5,Pocket PC,和任何其他mobile device(以下表中所列),来打开页面
http://localhost/Name/Name.aspx 来测试这个项目。
======================
Currently Tested Devices
Pocket PC
Sony CMD-z5 with Microsoft Mobile Explorer
Mitsubishi T250
Nokia 7110
Sprint Touchpoint
Samsung Touchpoint
Simulator for Microsoft Mobile Explorer version 2.01
Simulator for Phone.com UP 3.2
Simulator for Nokia 7110
Simulator for Phone.com UP 4.0
Personal computer with Microsoft Internet Explorer 5.5
============================
Conclusion
下一代的Microsoft Visual Studio开发工具将大大减少了创建mobile Web Applications的复杂性。使用VS.NET,你将能为各种设备开发Web applications,而不需要去学习各种各样的标志语言。利用开发mobile Web applications的单一化技术和一些已有的工业标准,如Extensible Markup Language(XML),Wrieless Application Protocol(WAP).我们将能开发下一代mobile Web applications。
上一页 [1] [2]