用户名: 密码: 免费注册 忘记密码? 网站地图 | 加入收藏 | 设为首页
首页 | 新闻 | 工具 | 系统 | 办公 | 聊天 | 多媒体 | 网页 | 运营 | 平面 | 欣赏 | 数据库 | 程序 | 服务器 | 组网
网页 | 3dmax | Ghost | Windows Xp| Dreamweaver | photoshop | Flash | office | Alexa | Css | QQ | Asp | PHP | Jsp | Access
Flash MX 2004入门 | 网站推广策略 | CorelDRAW入门 | ASP学习 | 网站建设大师功 | Word入门
  iTbulo.com > 学院 > 程序开发教程 > ASP.net教程 > Asp.Net实例教程 > 正文
ASP.NET移动开发之SelectionList控件
iTbulo.COM 2007-5-13 轩辕南宫()


  Default.aspx.cs

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.MobileControls.MobilePage
{
protected void HandleSingleSelection(object sender, EventArgs e)
{
this.ActiveForm = Form2;
String selectedMobile = SelectionList1.Selection.Value;
Label3.Text = SelectionList1.Selection + selectedMobile;
}
}

  程序代码说明:HandleSingleSelection就是Command控件的OnClick事件的处理函数。一旦用户点击了该Command按钮,将使Form2成为活动窗体。并在Label3控件上将选中的数据项的字符信息和隐藏值显示出来。

  如果你不在移动Web.Config文件中设置如下的代码,则在Openwave浏览器中会出错:

<sessionState mode="InProc" cookieless="true" timeout="20"></sessionState>

  为此你最好将如下的移动Web.Config配置代码替代Visual Studio自动生成的移动Web.Config配置代码:

  Web.Config

<?xml version="1.0"?>
<!-- 注意: 除了手动编辑此文件以外,您还可以使用 Web 管理工具来

  配置应用程序的设置。可以使用 Visual Studio 中的"网站"->"ASP.NET 配置"选项。

  设置和注释的完整列表在machine.config.comments 中,该文件通常位于 \Windows\Microsoft.NET\Framework\v2.0.xxxxx\Config 中
-->
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
设置 compilation debug="true" 将调试符号插入已编译的页面中。
但由于这会影响性能,因此只在开发过程中将此值设置为 true。
-->
<compilation debug="true"/>
<!--
通过 <authentication> 节可以配置 ASP.NET 使用的
安全身份验证模式,以标识传入的用户。
-->
<authentication mode="Windows"/>
<!--
如果在执行请求的过程中出现未处理的错误,则通过 <customErrors> 节
可以配置相应的处理步骤。具体说来,开发人员通过该节可以
配置要显示的 html 错误页以代替错误堆栈跟踪。
-->
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<!--
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
-->
</customErrors>
<!--
完全限定客户端重定向的 URL
有些移动设备要求对客户端重定向的 URL 进行完全限定。
-->
<httpRuntime useFullyQualifiedRedirectUrl="true"/>
<!--
指定无 Cookie 的数据字典类型
这将使字典内容出现在本地请求 url 查询字符串中。
这是在无 Cookie 的设备上进行 Forms 身份验证所必需的。
-->
<mobileControls cookielessDataDictionaryType="System.Web.Mobile.CookielessData"/>

<sessionState mode="InProc" cookieless="true" timeout="20"></sessionState>

<deviceFilters>
<filter name="isJPhone" compare="Type" argument="J-Phone"/>
<filter name="isHTML32" compare="PreferredRenderingType" argument="html32"/>
<filter name="isWML11" compare="PreferredRenderingType" argument="wml11"/>
<filter name="isCHTML10" compare="PreferredRenderingType" argument="chtml10"/>
<filter name="isGoAmerica" compare="Browser" argument="Go.Web"/>
<filter name="isMME" compare="Browser" argument="Microsoft Mobile Explorer"/>
<filter name="isMyPalm" compare="Browser" argument="MyPalm"/>
<filter name="isPocketIE" compare="Browser" argument="Pocket IE"/>
<filter name="isUP3x" compare="Type" argument="Phone.com 3.x Browser"/>
<filter name="isUP4x" compare="Type" argument="Phone.com 4.x Browser"/>
<filter name="isEricssonR380" compare="Type" argument="Ericsson R380"/>
<filter name="isNokia7110" compare="Type" argument="Nokia 7110"/>
<filter name="prefersGIF" compare="PreferredImageMIME" argument="image/gif"/>
<filter name="prefersWBMP" compare="PreferredImageMIME" argument="image/vnd.wap.wbmp"/>
<filter name="supportsColor" compare="IsColor" argument="true"/>
<filter name="supportsCookies" compare="Cookies" argument="true"/>
<filter name="supportsJavaScript" compare="Javascript" argument="true"/>
<filter name="supportsVoiceCalls" compare="CanInitiateVoiceCall" argument="true"/>
</deviceFilters>
</system.web>
</configuration>

  下面的是Pocket IE和Openwave浏览器在运行该程序时的截图:


文章搜索
相关资讯
相关文章 相关下载
ASP.NET定时自动更新页面的
ASP.NET中为GridView添加删除提示框
在ASP.NET 2.0中使用样式、主题和皮肤
讲解用.NET编写串口程序的一点心得
理解ASP.NET与客户端缓存之HTTP协议
焦点信息