您现在的位置是: 软件 > 开发者网络 > 程序方舟 > 嵌入式开发 > 正文
·速成电脑精英(包分配)白领高薪一族从这里开始



-Java套接字编程(下)
-MediaStudio Pro 6.5教程
-三款卸载软件最新试用
-基于Visual C++的Winsock API研究

用Mobile Web Form创建移动网络应用程序
2002-04-08· · ··Microsoft

上一页  1 2 3 4  

  Microsoft Mobile Internet Toolkit和命令行

  Visual Studio .NET Beta 2 把Mobile Internet Toolkit 直接集成到开发环境中,使很多设计、开发和调试变为自动化。但是,移动应用程序也可以使用你所喜欢的编辑器、Mobile Internet Toolkit和命令行编译来手动创建。下面的例子演示了如何使用C#去做这件事情。它也演示了你怎么从Command控制来处理OnClick 事件。当代码接收到这个事件,它按程序导航到另一个窗体。一个新的有活性的窗体产生OnActivate 事件,你可以控制它来对窗体初始化。

  创建NameApp

  1.在一个运行Windows 2000 Server或有Service Pack 1的Windows 2000 Professional操作系统的非产品测试计算机上,创建目录C:\Inetpub\wwwroot\Name。
  2.从Internet Services Manager ,展开Default Web Site 列表,右键单击Name (虚拟根 ),然后点击Properties。
  3.在Application Settings 下面, Application Name的右边,点击Create 按钮。

  在下面的例子中,你将在Name 目录中创建两个文件。

  ·Name.aspx是用户界面文件,根据客户设备,它包含了大量服务器端控制和HTML 3.2, cHTML或 WML 1.1的环境翻译。
  ·Name.cs是后台代码文件,它是一个编译好的C#部件。这个文件的扩展名根据编写它所用的语言是不同的。如果部件是一个Visual Basic部件,这个文件名称就是Name.vb。

  创建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 文件

  1.在Name目录中创建一个文件夹命名的扩展名。
  2.在命令行提示输入下面的代码来编译Name.cs 文件:
  3.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将使你可以创建下一代移动网络应用程序。

  通过访问Mobile Newsgroup来与你的同行交流关于移动网络窗体的消息。注意,你可以使用任何新闻阅读软件来访问这些新闻组。但是,我们建议从Microsoft Internet Explorer 主页下载Outlook Express。要得到更多关于访问新闻组的信息,参观MSDN Web site。

上一页  1 2 3 4  

■ 相关内容
 设计应用程序的用户界面
 创建移动Windows DNA 应用程序(一)
 Microsoft Mobile Internet Toolkit 评论家向导
 使用C#轻松编写.Net组件
 Visual C++ .Net编程实战
 .Net体系结构指导
 .Net开发平台(下)
 .Net开发平台(上)
 关于移动PC的报道
感谢 访问天极网,如果您觉得该文章涉及版权问题,请看这里!