译者有话要说:

我是完全按照此文设置的,但是由于现在大部分手机不支持wml脚本,导致项目中无法使用它。

这真是个悲剧!

+++++++++++++++++++++++++++++++++++++++
如何在MMIT上使用WMLScript文件

----------------------------------------------------------------------------
---
文章中的信息适用于:

- 微软移动网络开发工具集(Microsoft Mobile Internet Toolkit (MMIT))
----------------------------------------------------------------------------
---

概要
=======

要完成的任务

- 概要
- 创建一个WMLScript文件
- 创建一个移动Web窗体页面
- 配置系统
- 配置IIS的MIME类型

本文将向您演示如何在MMIT页面上使用包含WMLScript的文件(.wmls)。本文中的例子使用一个脚本来计算来自SelectionList上的选项的两个数。

创建WMLScript文件
-------------------------

创建一个名为Math.wmls的文件并加入如下代码:

extern function ComputeNums(func2Call, x, y) { var retVal = 0; if(func2Call == 1) { retVal = Add(x, y); } else if(func2Call == 2) { retVal = Subtract(x, y); } else if(func2Call == 3) { retVal = Multiply(x, y); } else if(func2Call == 4) { retVal = Divide(x, y); } WMLBrowser.setVar("TextBox3", retVal); WMLBrowser.refresh(); } function Add(x, y) { return (x + y); } function Subtract(x, y) { return(x - y); } function Multiply(x, y) { return(x * y); } function Divide(x, y) { return(x / y); }

创建一个移动Web窗体页面

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

使用WML脚本的重点是只有WML客户接收WML脚本。

这可以通过使用DeviceSpecific类创建一个基于WML硬件的过滤器来完成。一旦定义了DeviceSpecific类,一个脚本模板(ScriptTemplate)就可以用来为页面插入WML脚本了。创建一个名为UseScriptFile.aspx的文件和刚刚的脚本在同一目录并加入下面代码来说明如何创建DeviceSpecific过滤器:

<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <%@ Page language="c#" Inherits="System.Web.UI.MobileControls.MobilePage" %> <mobile:Form id=Form1 runat="server"> <mobile:SelectionList ID="computeType" Runat=server SelectType=Radio Title="Operation"> <Item Text="Add" Value="1" Selected=True></Item> <Item Text="Subtract" Value="2"></Item> <Item Text="Multiply" Value="3"></Item> <Item Text="Divide" Value="4"></Item> </mobile:SelectionList> <mobile:TextBox id=TextBox1 runat="server" Text="2"></mobile:TextBox> <mobile:TextBox id=TextBox2 runat="server" Text="3"></mobile:TextBox> <mobile:TextBox id=TextBox3 runat="server" Text=""></mobile:TextBox> <DeviceSpecific> <Choice Filter="isWML11"> <scriptTemplate> <do type="accept" label="Compute"> <go href="Math.wmls#ComputeNums($(computeType), $(TextBox1), $(TextBox2))" mce_href="Math.wmls#ComputeNums($(computeType), $(TextBox1)," /> </do> </scriptTemplate> </Choice> </DeviceSpecific> </mobile:Form>

注意:上面的示例代码并不能在非WML设备上正常处理。这需要使用一个移动命令控件(Command)并为其创建一个postback事件,或者创建一个客户端脚本给非WML设备来使用脚本模板(ScriptTemplate)。

配置系统
--------------------
在过滤器中使用DeviceSpecific类时,设备过滤器(DeviceFilters)部分需要在web.config文件进行配置。下面是过滤WML设备的例子。在相同目录下创建一个名为web.config的文件并加入如下代码:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <deviceFilters> <filter name="isWML11" compare="PreferredRenderingType" argument="wml11" /> </deviceFilters> </system.web> </configuration>

配额IIS MIME类型
---------------------------

你需要在IIS上配置WML脚本的MIME类型(资源的媒体类型)才能够成功的使用WML脚本。可以按照如下步骤完成:

1、在Web服务器上打开网络服务管理器。

2、右键点击机器名称并点击“属性”。

3、在计算机属性对话框的IIS上点击“编辑”按钮找到“计算机MIME映射”("Computer MIME Map")部分。

4、在“文件类型”的对话框,点击“新类型...”按钮。

5、在“文件类型”对话框,输入“.wmls”在“关联扩展”("Associated extension")文本框。在"Content Type (MIME)"对话框输入"text/vnd.wap.wmlscript"。

6、点击“确定”按钮关闭“文件类型”("File Type")对话框。

7、点击“确定”按钮关闭“文件类型”("File Types")对话框。

8、点击“确定”按钮关闭 计算机属性对话框。

9、重启IIS.

+++++++++++++++++++++++++++++++++++++++

原文:http://www.dotnet247.com/247reference/msgs/20/103177.aspx

+++++++++++++++++++++++++++++++++++++++
HOW TO: How To Use WMLScript Files With MMIT [idea]

----------------------------------------------------------------------------
---
The information in this article applies to:

- Microsoft Mobile Internet Toolkit (MMIT)
----------------------------------------------------------------------------
---

SUMMARY
=======

IN THIS TASK

- SUMMARY
- Create The WMLScript File
- Create A Mobile Web Form Page
- Configure the System
- Configure the IIS MIME Type

This article will demonstrate how to include WMLScript files (.wmls) for use
within Microsoft Mobile Internet Toolkit (MMIT) pages. The example in this
article will use a script which will compute two numbers based on the
selection
of a SelectionList.

Create The WMLScript File
-------------------------

Create a file named Math.wmls and add the following code:

extern function ComputeNums(func2Call, x, y)
{
    var retVal = 0;

if(func2Call == 1)
    {    
        retVal = Add(x, y);
    }
    else if(func2Call == 2)
    {
        retVal = Subtract(x, y);
    }
    else if(func2Call == 3)
    {
        retVal = Multiply(x, y);
    }
    else if(func2Call == 4)
    
    {
        retVal = Divide(x, y);
    }

WMLBrowser.setVar("TextBox3", retVal);
    WMLBrowser.refresh();
}

function Add(x, y)
{    
    return (x + y);
}

function Subtract(x, y)
{    
    return(x - y);
}

function Multiply(x, y)
{    
    return(x * y);
}

function Divide(x, y)
{    
    return(x / y);
}

Create A Mobile Web Form Page
-----------------------------

When working with WML Script it is important that only WML clients receive
the
WML Script. This can be accomplished by using the DeviceSpecific class to
create
a filter for WML based devices. Once the DeviceSpecific class is defined, a
ScriptTemplate can be used to insert WML Script into the page. Create a file
named UseScriptFile.aspx in the directory where the Math.wmls is located
and add
the following code that illustrates how to create a DeviceSpecific filter:

<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<%@ Page language="c#"
Inherits="System.Web.UI.MobileControls.MobilePage" %>

<mobile:Form id=Form1 runat="server">
<mobile:SelectionList ID="computeType" Runat=server SelectType=Radio
Title="Operation">
<Item Text="Add" Value="1" Selected=True></Item>
<Item Text="Subtract" Value="2"></Item>
<Item Text="Multiply" Value="3"></Item>
<Item Text="Divide" Value="4"></Item>    
</mobile:SelectionList>
<mobile:TextBox id=TextBox1 runat="server" Text="2"></mobile:TextBox>
<mobile:TextBox id=TextBox2 runat="server" Text="3"></mobile:TextBox>
<mobile:TextBox id=TextBox3 runat="server" Text=""></mobile:TextBox>

<DeviceSpecific>

<Choice Filter="isWML11">
<scriptTemplate>
<do type="accept" label="Compute">
<go href="Math.wmls#ComputeNums($(computeType), $(TextBox1),
$(TextBox2))" />
</do>
</scriptTemplate>

</Choice>

</DeviceSpecific>

</mobile:Form>

Note: The sample code above does not handle processing for non-WML devices.
This
may require using a mobile Command control and creating a postback event for
that control, or creating client side script for non-WML devices using a
ScriptTemplate.

Configure The System
--------------------

A DeviceFilters section is required in the web.config file when using the
DeviceSpecific class with a filter. Below is a sample of a device filter
for WML
based devices. Create a file named web.config in the directory where the
UseScriptFile.aspx is located and add the following lines of code:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<deviceFilters>
<filter name="isWML11" compare="PreferredRenderingType"
argument="wml11" />
</deviceFilters>
</system.web>
</configuration>

Configure the IIS MIME Type
---------------------------

You will need to configure a WML Script MIME type in Internet Information
Server
(IIS) in order for the WML Script to run successfully. This can be done by
using
the following steps:

1. Open the Internet Services Manager on the web server.

2. Right-click the machine name in the left pane and click "Properties".

3. Click the "Edit" button found in the "Computer MIME Map" section on the
"Internet Information Services" tab of the computer properties dialog.

4. In the "File Types" dialog, click the "New Type..." button.

5. In the "File Type" dialog, enter ".wmls" in the "Associated extension"
textbox. Enter "text/vnd.wap.wmlscript" in the "Content Type (MIME)"
dialog.

6. Click the "OK" button to close the "File Type" dialog.

7. Click the "OK" button to close the "File Types" dialog.

8. Click the "OK" button to close the machine properties dialog.

9. Right-click the machine name in the left pane and click "Restart IIS...".

+++++++++++++++++++++++++++++++++++++++

如何在MMIT上使用WMLScript文件(How To Use WMLScript Files With MMIT)相关推荐

  1. ntfs硬盘如何在mac上读写移动硬盘文件?

    在日常的工作中,总是避免不了跨平台的传输文件.文件共享等,例如一些用户使用Mac电脑修图或者剪辑视频之后需要拷贝到Windows电脑上查看.对于需要同时使用Mac和Windows的用户来说,系统之间不 ...

  2. linux swf文件打开_如何在Linux上播放.swf文件?

    linux swf文件打开 How to play the flash (.swf) files downloaded from the Web on Linux? 如何在Linux上播放从Web下载 ...

  3. linux中fstab文件的作用,如何在Linux上写入fstab文件 | MOS86

    在Linux计算机上添加新的硬盘驱动器或固态驱动器? 您需要编辑fstab文件. 很多人觉得这个主意很吓人. 是的,至关重要的是您要正确,但掌握了正确的知识,这确实并不困难. 我们将引导您完成编辑fs ...

  4. MAC |如何在mac上阅读caj文件?

    背景:工作群中老板突然发了一个caj的论文过来,让大家阅读学习. 于是就开启了解决:在mac上阅读caj文件之旅. 首先,尝试了这篇文章的方法: 教你如何在Mac上打开CAJ格式的文件_普通网友的博客 ...

  5. 如何在 Mac 上播放 WMV 文件

    Windows Media Video (.wmv) 是 Windows 上流行的视频文件格式之一,但是当尝试在 Mac 上播放 WMV 文件时,您可能会遇到兼容性问题.如果您在 Mac 上打开或播放 ...

  6. linux创建交换分区设置_如何在Linux上创建交换文件

    linux创建交换分区设置 zentilia/Shutterstock.com zentilia / Shutterstock.com Add swap space to a Linux comput ...

  7. 如何在GitHub上下载开源文件

    具体实现步骤 1 . 在本地安装Git,下载地址:点击下载 2 . 下载完成后开始安装,安装过程勾选下面内容: 1. Git Bash here 2. Git GUI here 然后一直点击next, ...

  8. linux中fstab文件_如何在Linux上写入fstab文件

    linux中fstab文件 zentilia/Shutterstock.comzentilia / Shutterstock.com Adding a new hard drive or solid- ...

  9. 如何在xmd上运行java文件,Junit命令行应用

    今天, 同事来找, 有个需求, 大概是这样子, 想用crontab shell方式跑我们现在的SpringBoot项目代码, 他的代码写在了测试类里, 不想启动SpringBoot服务. 之前写spr ...

  10. 如何在linux上打开fit文件,FIT 文件扩展名: 它是什么以及如何打开它?

    FIT 疑难解答 频繁的 FIT 打开问题 Garmin Connect 已删除 如果您尝试加载 FIT 文件,则会收到 "无法打开 FIT 文件" 等消息. 如果是这样,这通常意 ...

最新文章

  1. 前端基础---HTML
  2. 注册服务(addService)
  3. oracle导入脚本乱码,imp导入乱码解决
  4. 注解@PostConstruct与@PreDestroy
  5. mysql binlog过期策略_对存在过期 binlog 的 MySQL5.7 添加从服务器
  6. 被抖音公司开除了....
  7. Vue三大核心概念之一(属性)
  8. 笨办法学python 3 48题_附录练习 8-10 笨办法学Python3
  9. 大学生创新创业大赛 项目申请书
  10. 安装虚拟机时勾选增强型键盘驱动程序有什么用?(在软件安装或者升级时候没勾选怎么办)
  11. 采购很容易,油水又多?那你来啊
  12. red5简介及基础知识
  13. 手机语言 Symbian 术语表
  14. 成本太高,京东配送扛不住了?
  15. ESD门禁管理系统方案
  16. 目前重庆橱柜市场分析
  17. 超感猎杀/超感八人组第一季至二季/全集Sense8迅雷下载
  18. 数据结构 严慰敏(C语言版第2版)【习题答案】
  19. postgresql windows下修改帐号密码 (图文)
  20. SQL---日期时间函数

热门文章

  1. JavaScript原生自动触发事件
  2. centos 7 iso u盘安装_服务器系统CentOS安装教程
  3. Python基础入门:条件语句--阿里云天池
  4. 文件或目录损坏其无法读取问题解决方法2022-9-15
  5. 可变参数模板实现可变参数字符串一定程度替代sprintf
  6. 查询加日期oracle,Oracle查询优化日期运算实例详解
  7. centos 硬盘分区容量调整
  8. 怎样使控件的背景色为透明色?
  9. 大数据技术之Hadoop(HDFS)第2章 HFDS的Shell操作
  10. 2021ASC超算竞赛QuEST配置与实战(量子计算)