MBL300 如何使用ASP.NET Mobile Controls开发Mobile...
Transcript of MBL300 如何使用ASP.NET Mobile Controls开发Mobile...
TechEd 2005 2005年9月28日5时54分
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 1
MBL300MBL300如何使用如何使用ASP.NET Mobile ASP.NET Mobile ControlsControls开发开发Mobile WebMobile Web应用应用
马骐马骐( ( [email protected]@hotmai.com ))微软 有价值专家,微软认证讲师微软 有价值专家,微软认证讲师中国移动聊天微软中国移动聊天微软m161 WAPm161 WAP项目组项目组
MManagementanagementTToolsools
CCommunicationsommunications& & MMessagingessaging
Device Update AgentSoftware Update Services
Live Communications ServerExchange Server
Internet Security and Acceleration Server
Speech Server
Image Update
LLocation ocation SServiceservices
MMultimediaultimedia
MapPoint
DirectXWindows Media
Visual Studio 2005DDevelopment evelopment TToolsools
MFC 8.0, ATL 8.0Win32NNativeative
MManagedanagedSServer erver SSideide
LLightweightightweightRRelationalelational
SQL Server 2005 Express EditionEDB
DDat
aat
aPP r
ogra
mm
ing
rogr
amm
ing
MMod
elod
el
DDevice evice BBuilding uilding TToolsools
HHardware/ardware/DDriversrivers
Windows XP DDKWindows Embedded
StudioPlatform Builder
OEM/IHV Supplied BSP(ARM, SH4, MIPS)
OEM Hardware and Standard Drivers
Standard PC Hardware and Drivers
SQL Server 2005SQL Server 2005 Mobile Edition
ASP.NET Mobile Controls ASP.NET.NET Compact Framework .NET Framework
Microsoft Operations ManagerSystems Management Server
Session PrerequisitesSession Prerequisites
不需要任何技术背景,但不需要任何技术背景,但……假如理解假如理解ASP.NETASP.NET会很有帮助会很有帮助
日程安排日程安排
空前的无线增值行业发展速度空前的无线增值行业发展速度
Windows Mobile WebWindows Mobile Web当前开发技术当前开发技术
存在的挑战及解决办法存在的挑战及解决办法
手持设备适配信息和设备适配库手持设备适配信息和设备适配库
使用使用Device FiltersDevice Filters定制定制
使用模板定制使用模板定制FormsForms和和PanelsPanels
在在XHTMLXHTML浏览器中使用浏览器中使用CSS CSS StylesheetsStylesheets
空前的无线增值行业发展速度空前的无线增值行业发展速度
无线增值行业的发展速度几乎可以用空前来形容无线增值行业的发展速度几乎可以用空前来形容
中国联通、中国电信、中国网通也开始启动类似于中国联通、中国电信、中国网通也开始启动类似于MISCMISC平台的管理办法平台的管理办法
中移动分成新政出水中移动分成新政出水 SPSP淘汰战一触即发淘汰战一触即发
20052005年年88月伊始,中国移动一项新的月伊始,中国移动一项新的SPSP分成政策分成政策
打破中国移动与打破中国移动与SPSP之间一成不变的之间一成不变的1515::8585分成模式分成模式
高可达到高可达到5050::5050
中移动的目标中移动的目标构建一个大量构建一个大量CPCP+少数大+少数大SPSP+移动运营商+移动运营商””的移动增值的移动增值服务产业链服务产业链
中小公司的转变中小公司的转变
服务提供商服务提供商-->>内容提供商内容提供商-->>技术提供商的转变技术提供商的转变
TechEd 2005 2005年9月28日5时54分
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 2
日程安排日程安排
空前的无线增值行业发展速度空前的无线增值行业发展速度
Windows Mobile WebWindows Mobile Web当前开发技术当前开发技术
存在的挑战及解决办法存在的挑战及解决办法
手持设备适配信息和设备适配库手持设备适配信息和设备适配库
使用使用Device FiltersDevice Filters定制定制
使用模板定制使用模板定制FormsForms和和PanelsPanels
在在XHTMLXHTML浏览器中使用浏览器中使用CSS CSS StylesheetsStylesheets
Windows Mobile WebWindows Mobile Web当前开发技术当前开发技术
DisplayDisplayUSB or SerialUSB or Serial
ProcessorProcessorMemoryMemory
GSM/GPRSGSM/GPRSCDMA/1xRTTCDMA/1xRTT
Device Device HardwareHardware
WiFiWiFiBluetoothBluetooth
RadioRadioDriversDrivers
Windows MobileWindows Mobile CE DBCE DBActiveSyncActiveSync
Pocket OutlookPocket OutlookPocket Internet ExplorerPocket Internet ExplorerWindows Media PlayerWindows Media Player
Windows CEWindows CE
Software Platform (APIs)Software Platform (APIs)
Home ScreenHome ScreenUser Interface/ShellUser Interface/ShellHTML ControlHTML Control
GAPIGAPIRemote APIRemote APIConfigurationConfigurationBluetoothBluetoothSecuritySecurity
Connection ManagerConnection ManagerTAPITAPISMS SMS MAPI MAPI POOM POOM ActiveSyncActiveSync
MultimediaMultimediaCommunicationCommunicationDevice ManagementDevice Management PresentationPresentation
ADO CEADO CEXMLXMLCE DBCE DBOLE DBOLE DB
Data AccessData Access
NativeNative
Win32Win32
MFCMFC ATLATLManagedManaged
.NET Compact.NET CompactFrameworkFramework
Server sideServer sideASP .NETASP .NET
Mobile ControlsMobile Controls
NativeNative
Win32Win32
MFCMFC ATLATLManagedManaged
.NET Compact.NET CompactFrameworkFramework
Server sideServer sideASP .NETASP .NET
Mobile ControlsMobile Controls
Embedded VC++Embedded VC++ Visual Studio .NETVisual Studio .NET
ASP.NETASP.NET移动移动WebWeb应用技术的时间线应用技术的时间线
.NET Framework 1.0.NET Framework 1.0
ASP.NET 1.0ASP.NET 1.0
Visual Studio .NETVisual Studio .NET
03/200203/200204/200204/2002
Mobile Internet Mobile Internet Toolkit 1.0Toolkit 1.0
.NET Framework 1.1.NET Framework 1.1
ASP.NET 1.1ASP.NET 1.1
ASP.NET 1.1 Mobile ASP.NET 1.1 Mobile ControlsControls
Visual Studio .NET 2003Visual Studio .NET 2003
07/200307/2003
.NET Framework 2.0.NET Framework 2.0
ASP.NET 2.0ASP.NET 2.0
ASP.NET 1.1 Mobile ASP.NET 1.1 Mobile ControlsControls
Visual Studio 2005 Beta 2Visual Studio 2005 Beta 2
04/200504/2005
ASP.NET 1.1 ASP.NET 1.1 移动控件移动控件
在在VS2003VS2003中已经包括了移动控件中已经包括了移动控件MobileMobile ControlsControlsMobile ControlMobile Control是是Mobile Internet Toolkit 1.0 Mobile Internet Toolkit 1.0 controlscontrols的更新的更新
使用使用ASP.NET Mobile WebASP.NET Mobile Web应用项目类型应用项目类型
发布了四次设备更新发布了四次设备更新支持更多的新设备支持更多的新设备
DU2DU2增加了增加了 XHTMLXHTML设备适配器设备适配器
DU4DU4是 后一次发布是 后一次发布
成熟的技术,只有出现象新的标记语言时才会出现新的成熟的技术,只有出现象新的标记语言时才会出现新的发布发布
设备适配信息收集工具设备适配信息收集工具http://www.asp.net/mobile/profile/default.aspxhttp://www.asp.net/mobile/profile/default.aspx
允许开发人员为特定设备允许开发人员为特定设备<<browserCapsbrowserCaps>>中的定义中的定义
使用使用ASP.NET 2.0ASP.NET 2.0开发移动开发移动WebWeb应用应用
使用使用Asp.net.20Asp.net.20服务器控件创建的新型控件服务器控件创建的新型控件适配器框架适配器框架和和ASP.NET 1.1 Mobile ControlsASP.NET 1.1 Mobile Controls框架类似框架类似
允许允许ASP.NET 2.0ASP.NET 2.0服务器控件为各种浏览器服务器控件为各种浏览器((不不限于移动设备的浏览器限于移动设备的浏览器))创建丰富的表现形式创建丰富的表现形式
Visual Studio 2005 Beta 1Visual Studio 2005 Beta 1包括了包括了ASP.NET ASP.NET 2.02.0服务器控件移动设备适配器的例子服务器控件移动设备适配器的例子
Beta 2 Beta 2 以后的没有包括任何移动设备适配器以后的没有包括任何移动设备适配器
ASP.NET 2.0 ASP.NET 2.0 中包括中包括ASP.NET 1.x ASP.NET 1.x 移动控件移动控件包括从包括从1.x1.x到到DU4DU4的设备适配器和浏览器定义的设备适配器和浏览器定义
ASP.NET 2.0ASP.NET 2.0主要针对于主要针对于xHtmlxHtml的手持设备的手持设备
日程安排日程安排
空前的无线增值行业发展速度空前的无线增值行业发展速度
Windows Mobile WebWindows Mobile Web当前开发技术当前开发技术
存在的挑战及解决办法存在的挑战及解决办法
手持设备适配信息和设备适配库手持设备适配信息和设备适配库
使用使用Device FiltersDevice Filters定制定制
使用模板定制使用模板定制FormsForms和和PanelsPanels
在在XHTMLXHTML浏览器中使用浏览器中使用CSS CSS StylesheetsStylesheets
TechEd 2005 2005年9月28日5时54分
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 3
存在的挑战及解决办法存在的挑战及解决办法
终端的限制终端的限制
不同的设备有不同的性能不同的设备有不同的性能
多种标记语言多种标记语言(WML, XHTML, (WML, XHTML, cHTMLcHTML, HTML), HTML)
各式各样的浏览器各式各样的浏览器
WAPWAP标准各种实现标准各种实现
客户端处理验证的能力不同客户端处理验证的能力不同
是否支持是否支持CookieCookie的实现的实现
集成不同状态管理方法集成不同状态管理方法
不同设备分页的需求不同设备分页的需求
开发调试应用程序的环境开发调试应用程序的环境
存在的挑战及解决办法存在的挑战及解决办法
新技术配合对终端的限制有所突破新技术配合对终端的限制有所突破ASP.netASP.net 1.1 Mobile Control1.1 Mobile ControlAsp.netAsp.net 2.02.0新框架新框架
存在的普遍问题存在的普遍问题对新设备的支持对新设备的支持
使用使用设备适配信息收集工具设备适配信息收集工具修改修改WML, WML, cHtmlcHtml, XHTML, HTML, XHTML, HTML适配器源代码适配器源代码
ButtonButton的问题的问题修改修改WML, WML, cHtmlcHtml, XHTML, HTML, XHTML, HTML适配器源代码适配器源代码使用使用LinkLink代替代替ButtonButton使用使用Form ActiveForm Active事件代替事件代替Button ClickButton Click事件事件
SessionSession和和ViewStateViewState的顾虑的顾虑对排版的局限性对排版的局限性
ASP.NET 1.1 Mobile ControlASP.NET 1.1 Mobile Control使用使用BreakAfterBreakAfter控制排版控制排版ASP.NET 2.0 ASP.NET 2.0 没有此限制没有此限制
日程安排日程安排
空前的无线增值行业发展速度空前的无线增值行业发展速度
Windows Mobile WebWindows Mobile Web当前开发技术当前开发技术
存在的挑战及解决办法存在的挑战及解决办法
手持设备适配信息和设备适配库手持设备适配信息和设备适配库
使用使用Device FiltersDevice Filters定制定制
使用模板定制使用模板定制FormsForms和和PanelsPanels
在在XHTMLXHTML浏览器中使用浏览器中使用CSS CSS StylesheetsStylesheets
手持设备适配信息手持设备适配信息
设备适配信息收集工具设备适配信息收集工具http://http://www.asp.net/mobile/profile/default.aspxwww.asp.net/mobile/profile/default.aspx
允许开发人员为特定设备允许开发人员为特定设备<<browserCapsbrowserCaps>>中的定义中的定义
使用程序自动分析请求头生成适配信息库使用程序自动分析请求头生成适配信息库UserUser--Agent=Dopod565 Mozilla/4.0 (compatible; Agent=Dopod565 Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; MSIE 4.01; Windows CE; SmartphoneSmartphone; 176x220); 176x220)
使用手机厂商提供的使用手机厂商提供的http://nds.nokia.com/uaprof/N6100r100.xmlhttp://nds.nokia.com/uaprof/N6100r100.xml
http://communicationhttp://communication--market.siemens.de/UAProf/SL56_10.xmlmarket.siemens.de/UAProf/SL56_10.xml
http://wap.samsungmobile.com/uaprof/e317.xmlhttp://wap.samsungmobile.com/uaprof/e317.xml
移动聊天移动聊天M161 M161 WapWap版有版有33千多种手设备的适配信息千多种手设备的适配信息库库
设备适配器源代码设备适配器源代码
根据请求设备的性能不同,同一控件输出不同内根据请求设备的性能不同,同一控件输出不同内容容
目前分成四组设备适配器集,每组分别对应一种目前分成四组设备适配器集,每组分别对应一种标记语言标记语言
WMLWML
HTMLHTML
cHTMLcHTML
xHTMLxHTML
每组都包括三大类不同的控件适配每组都包括三大类不同的控件适配页面适配页面适配
表单适配表单适配
控件适配控件适配 IISIISServerServer
Mobile.ASPXMobile.ASPX
PagePageInstantiates Instantiates ControlControl
Select
Sel
ect
Device
Adapt
er
Device
Adapt
er
Get Device Get Device AdapterAdapter
根据适配信息输出合适内容根据适配信息输出合适内容WSPWSP
RequestRequest
HTTPRequest
2aGet Brower &Device Properties
PagePageInstantiated Instantiated
3b4a
5a6a
HTTPResponse
Generate HTML with Generate HTML with alternative textalternative text
2b
3a4b
1b
Generate WML with the WTAI tagGenerate WML with the WTAI tag
7a
HTTPResponse
Get Device Get Device AdapterAdapter
8a
6b
7b 8b
5b
WAPGateway
1a
0 9
WSPWSPResponse Response
Mobile Capabilities
Application Application ControlControl
Device Device Adapter by Adapter by MarkMark--up up LanguageLanguage PhoneCallPhoneCall
ControlControl
cHTMLcHTML
WMLWML
HTMLHTML
TechEd 2005 2005年9月28日5时54分
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 4
M161 M161 WapWap版版33千多种手持设备千多种手持设备适配信息库适配信息库M161 M161 WapWap版扩展设备适配库版扩展设备适配库
日程安排日程安排
空前的无线增值行业发展速度空前的无线增值行业发展速度
Windows Mobile WebWindows Mobile Web当前开发技术当前开发技术
存在的挑战及解决办法存在的挑战及解决办法
手持设备适配信息和设备适配库手持设备适配信息和设备适配库
使用使用Device FiltersDevice Filters定制定制
使用模板定制使用模板定制FormsForms和和PanelsPanels
在在XHTMLXHTML浏览器中使用浏览器中使用CSS CSS StylesheetsStylesheets
使用设备过滤器定制使用设备过滤器定制
在表现形式中定制在表现形式中定制::
在代码中定制在代码中定制::
<mobile:Label id="Label2" Runat="server" Font-Bold="True"><DeviceSpecific>
<Choice Filter="isPocketIE" Text="...Breaking News - Breaking News...">
</Choice><Choice Text="News Just In! "></Choice>
</DeviceSpecific> </mobile:Label>
MobileCapabilities cap = (MobileCapabilities)Request.Browser;
if (cap.HasCapability(“isPocketIE“, null)){Label2.Text = "...Breaking News - Breaking News...“;
}Else Label2.Text = "News Just In! ";
定义定义Device FiltersDevice Filters
根据根据Device FiltersDevice Filters来决定如何定制以及来决定如何定制以及如何使用模板如何使用模板
Visual Studio .NETVisual Studio .NET在在Web.configWeb.config中创建中创建一系列默认的设备过滤器一系列默认的设备过滤器
<deviceFilters><filter name="isHTML32" compare="PreferredRenderingType"
argument="html32" /><filter name="isWML11" compare="PreferredRenderingType"
argument="wml11" /><filter name="isPocketIE" compare="Browser"
argument="Pocket IE" /><filter name="prefersGIF" compare="PreferredImageMIME"
argument="image/gif" /><filter name="prefersWBMP" compare="PreferredImageMIME"
argument="image/vnd.wap.wbmp" />...
</deviceFilters>
可以用代码编写设备过滤器可以用代码编写设备过滤器
在在Web.configWeb.config中的设备过滤器只是简单比中的设备过滤器只是简单比较较
CompareCompare属性指的是属性指的是 MobileCapabilitiesMobileCapabilities对象对象的名称的名称
假如指定属性与指定参数相等,设备过滤器为假如指定属性与指定参数相等,设备过滤器为真真
<deviceFilters><filter name="isHTML32"
compare="PreferredRenderingType" argument="html32" />
</deviceFilters>
可以通过代码编写复杂的设备过滤器可以通过代码编写复杂的设备过滤器
日程安排日程安排
空前的无线增值行业发展速度空前的无线增值行业发展速度
Windows Mobile WebWindows Mobile Web当前开发技术当前开发技术
存在的挑战及解决办法存在的挑战及解决办法
手持设备适配信息和设备适配库手持设备适配信息和设备适配库
使用使用Device FiltersDevice Filters定制定制
使用模板定制使用模板定制FormsForms和和PanelsPanels
在在XHTMLXHTML浏览器中使用浏览器中使用CSS CSS StylesheetsStylesheets
TechEd 2005 2005年9月28日5时54分
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 5
使用模板定制使用模板定制
模板才是真正的定制模板才是真正的定制
在在<<mobile:DeviceSpecificmobile:DeviceSpecific>>使用模板使用模板
Control Template Usage
HeaderTemplateHeaderTemplateRenders contents at head of every Renders contents at head of every output pageoutput page
FooterTemplateFooterTemplateRenders contents at foot of every Renders contents at foot of every output pageoutput page
ScriptTemplateScriptTemplate
Can be used to define Can be used to define JavascriptJavascriptfunctions on HTML browsers, or to functions on HTML browsers, or to inject WML into markup sent to WML inject WML into markup sent to WML browsersbrowsers
PanelPanel ContentTemplateContentTemplateCan contain markup or server Can contain markup or server controls Injects content into controls Injects content into output streamoutput stream
FormForm
FormForm定制定制Header and FooteHeader and Footerr例子例子
<mobile:Form id="Form1" runat="server"><mobile:DeviceSpecific id="DeviceSpecific1" runat="server">
<Choice Filter="isHTML32"><HeaderTemplate>
<mobile:Label id="Label1" runat="server" StyleReference="title" ForeColor="Firebrick">
Contoso Inc.</mobile:Label></HeaderTemplate><FooterTemplate>
<mobile:Label id="Label2" runat="server" Font-Size="Small">(c) Contoso, 2004.</mobile:Label>
</FooterTemplate></Choice>
</mobile:DeviceSpecific>…
</mobile:Form>
在模板在插入标记语言在模板在插入标记语言
通过设备过滤器确定是否为通过设备过滤器确定是否为isHTML32isHTML32 还是还是isWMLisWML
<mobile:Form id="Form1" runat="server"><mobile:DeviceSpecific id="DeviceSpecific1" runat="server">
<Choice Filter="isHTML32"><HeaderTemplate>
<table width=“90%” cellspacing=“1”><tr><td bgcolor=“#003366” valign=“top” height=“100%”>
</HeaderTemplate><FooterTemplate>
</td></tr></table></FooterTemplate>
</Choice></mobile:DeviceSpecific>…
日程安排日程安排
空前的无线增值行业发展速度空前的无线增值行业发展速度
Windows Mobile WebWindows Mobile Web当前开发技术当前开发技术
存在的挑战及解决办法存在的挑战及解决办法
手持设备适配信息和设备适配库手持设备适配信息和设备适配库
使用使用Device FiltersDevice Filters定制定制
使用模板定制使用模板定制FormsForms和和PanelsPanels
在在XHTMLXHTML浏览器中使用浏览器中使用CSS CSS StylesheetsStylesheets
XHTMLXHTML浏览器和浏览器和CSSCSS
Cascading Style Sheets (CSS):Cascading Style Sheets (CSS):
佳的表现定义方法佳的表现定义方法
把表现和内容分开把表现和内容分开
W3CW3C推荐推荐 (CSS1)(CSS1)
支持主要的桌面浏览器支持主要的桌面浏览器
新的移动设备也支持新的移动设备也支持CSSCSS
SmartphoneSmartphone 20032003上的上的Pocket IEPocket IE支持支持HTML 4.01, XHTMLHTML 4.01, XHTML--BasicBasic以及以及 CSS1CSS1
WAP 2.0WAP 2.0设备支持设备支持XHTMLXHTML--MPMP和无线和无线CSS (Nokia Series 60, CSS (Nokia Series 60, SonySony--Ericsson Smartphones)Ericsson Smartphones)
ASP.NET Mobile Controls RuntimeASP.NET Mobile Controls Runtime
在在DU2DU2以后支持以后支持XHTMLXHTML浏览器浏览器
使用标准移动样式属性动态产生使用标准移动样式属性动态产生
使用使用CSSCSS--11编程编程
在项目中创建一个样式在项目中创建一个样式文件文件
.Subhead{
font-weight: bold;font-size: smaller;color: orangered;
}
<mobile:Form id="Form1" runat="server"csslocation="stylesheet1.css“ … >
<system.web><mobileControls allowCustomAttributes="true“ />
</system.web>
在在<<mobile:Formmobile:Form> > 增加增加CSSLocationCSSLocation属性指定样式属性指定样式文件位置文件位置
在在Web.configWeb.config中设置中设置allowCustomAttributesallowCustomAttributes==““truetrue””
TechEd 2005 2005年9月28日5时54分
© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 6
CSSCSS表现的例子表现的例子BODY
{
background-image:
url(Images/background.png);
background-color: #99ccff;
}
.dropcap
{
font-weight: bold;
font-size: 200%;
float: left;
width: 12pt;
color: orange;
}
在智能手中中使用在智能手中中使用CSSCSS
智能手机中的智能手机中的Pocket IEPocket IE是一个支持是一个支持多种标记语方的浏览器多种标记语方的浏览器HTML 4.01HTML 4.01XHTMLXHTML--BasicBasicCSS1CSS1
ASP.NET Mobile ControlsASP.NET Mobile Controls默认对默认对Pocket IEPocket IE为为HTML 3.2HTML 3.2浏览器浏览器 –– 不支不支持持CSS!CSS!为更新为更新Pocket IE V4.01Pocket IE V4.01适配信息库适配信息库(2003 version)(2003 version)指定为指定为XHTMLXHTML浏览器浏览器使用使用CSSCSS指定表现形式指定表现形式
CSS Style sheet
User Control (external style sheet)
StyleSheet
Mobile-CapabilitiesDeviceSpecific
Template
Property Override
Property Override
Mobile-Capabilities
Property Override
定制总结定制总结