在这篇文章中,你将学到创建移动网络应用程序的基本步骤。在你可以创建一个Mobile Web Forms 应用程序前,你需要安装Microsoft Visual Studio .NET Beta 2和Mobile Internet Toolkit Beta 2。
创建Name.aspx移动网络窗体
<%@ 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;
}
}
}
|
编译Name.cs 文件
- 在Name目录中创建一个文件夹命名的扩展名。
- 在命令行提示输入下面的代码来编译Name.cs 文件:
- C:\Inetpub\wwwroot\Name> csc /r:System.Web.dll /r:System.Web.Mobile.dll _ /target:library /out:bin\NameApp.dll Name.cs
在一个PC、一个Pocket PC或下面列出的任何现在的测试设备,浏览http://localhost/Name/Name.aspx并且测试应用程序。
当前测试的设备
◆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
结论
Microsoft Visual Studio 开发工具的下一代产品显著地减少了创建移动网络应用程序的复杂性。使用Visual Studio .NET ,你将可以从一个单独的ASP.NET页面,开发面向网络和事实上任何移动设备的应用程序-而不用学习各种各样的不同的标置语言。使用新的,简化了创建继承了对工业标准支持的移动网络应用程序的技术,例如Extensible Markup Language (XML) 和Wireless Application Protocol (WAP),Microsoft将使你可以创建下一代移动网络应用程序。
查看本文来源