在云那方

首页 新随笔 联系 订阅 管理

参考资料:

http://www.cnblogs.com/xy6521/articles/410595.html
http://www.cnblogs.com/yjmyzz/archive/2009/02/18/1392902.html
http://www.fool2fish.cn/?cat=5

 

选择用ASP.NET开发,ASP.NET开发WAP站点,实在简单,就是一个移动控件的运用,根本不用懂WML语法.唯一不同的,就是一个ASPX文件可以支持多个FORM,不同FORM之间可以切换,
最后ASP.NET根据访问的设备,输出不同的内容,
如果用IE访问就输出HTML,手机访问,输出WML,
不过在开发过程中也遇到了很多问题,一些问题总结如下:
1.模拟器:

代码
<table width="222"  border="0" cellpadding="0" cellspacing="0" id="bkimg" style="display:block"><tr><td height="71" colspan="3" align="left" valign="bottom">
<img src="http://www.roboo.com/pages/images/layout/phone_mb3_up.gif" width="222" height="82"  /></td></tr><tr><td width="28" height="205" align="left" valign="bottom">
<img src="http://www.roboo.com/pages/images/layout/phone_mb3_left.gif" width="28" height="240"  /></td><td width="167" valign="top" >
<iframe name="wbb" id="wbb"    marginheight="0" marginwidth="0" width="165px" height="240px" frameborder="0" src="http://www.roboo.com/pages/simulator/crawldatah.jsp?url=wap.56hui.com"></iframe> 
</td><td width="27" align="right" valign="top">
<img src="http://www.roboo.com/pages/images/layout/phone_mb3_right.gif" width="27" height="240"  /></td></tr><tr><td  colspan="3" align="left" valign="bottom">
<img src="http://www.roboo.com/pages/images/layout/phone_mb3_down.gif" width="222"  />
</td></tr></table>

将"http://www.roboo.com/pages/simulator/crawldatah.jsp?url=m.ta0bao.com"的"m.ta0bao.com"换成自己的wap地址


强制输出WML:
在web.config
添加下面内容<system.web>下

 

<browserCaps>
            
<result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            
<use var="HTTP_USER_AGENT"/>
                     preferredRenderingType = "wml11"
                     preferredRenderingMime = "text/vnd.wap.wml"
                     preferredImageMime = "image/vnd.wap.wbmp"
</browserCaps>


如果定义相关其它属性可以完整的移动设置属性:

    <browserCaps>
            
<result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            
<use var="HTTP_USER_AGENT"/>

             browser=Unknown
             version=0.0
             majorversion=0
             minorversion=0
             frames=false
             tables=false
             cookies=false
             backgroundsounds=false
             vbscript=false
             javascript=false
             javaapplets=false
             activexcontrols=false
             win16=false
             win32=false
             beta=false
             ak=false
             sk=false
             aol=false
             crawler=false
             cdf=false
             gold=false
             authenticodeupdate=false
             tagwriter=System.Web.UI.Html32TextWriter
             ecmascriptversion=0.0
             msdomversion=0.0
             w3cdomversion=0.0
             platform=Unknown
             css1=false
             css2=false
             xml=false

             mobileDeviceManufacturer = "Unknown"
             mobileDeviceModel = "Unknown"

             gatewayVersion = "None"
             gatewayMajorVersion = "0"
             gatewayMinorVersion = "0"

            preferredRenderingType = "wml11"
            preferredRenderingMime = "text/vnd.wap.wml"
            preferredImageMime = "image/vnd.wap.wbmp"

             defaultScreenCharactersWidth = "12"
             defaultScreenCharactersHeight = "6"
             defaultScreenPixelsWidth = "96"
             defaultScreenPixelsHeight = "72"
             defaultCharacterWidth = "8"
             defaultCharacterHeight = "12"
             screenBitDepth = "1"
             isColor = "false"
             inputType = "telephoneKeypad"

             numberOfSoftkeys = "0"
             maximumSoftkeyLabelLength = "5"

             canInitiateVoiceCall = "false"

             canSendMail = "true"
             hasBackButton = "true"
             rendersWmlDoAcceptsInline = "true"
             rendersWmlSelectsAsMenuCards = "true"
             rendersBreaksAfterWmlAnchor = "false"
             rendersBreaksAfterWmlInput = "false"
             rendersBreakBeforeWmlSelectAndInput = "true"
             requiresAttributeColonSubstitution = "true"
             requiresPhoneNumbersAsPlainText = "false"
             requiresUrlEncodedPostfieldValues = "false"
             requiredMetaTagNameValue = ""
             rendersBreaksAfterHtmlLists = "true"
             requiresUniqueHtmlCheckboxNames = "true"
             requiresUniqueHtmlInputNames = "true"
             requiresUniqueFilePathSuffix = "true"
             supportsCss = "false"
             hidesRightAlignedMultiselectScrollbars = "false"
             canRenderAfterInputOrSelectElement = "true"
             canRenderInputAndSelectElementsTogether = "true"
             canRenderOneventAndPrevElementsTogether = "true"
             canCombineFormsInDeck = "true"
             canRenderMixedSelects = "true"
             canRenderPostBackCards = "true"
             canRenderSetvarZeroWithMultiSelectionList = "true"
             supportsImageSubmit = "true"
             supportsSelectMultiple = "true"
             requiresHtmlAdaptiveErrorReporting = "false"
             requiresContentTypeMetaTag = "false"
             requiresDBCSCharacter = "false"
             requiresOutputOptimization = "false"
             supportsAccesskeyAttribute = "false"
             supportsInputIStyle = "false"
             supportsInputMode = "false"
             supportsIModeSymbols = "false"
             supportsJPhoneSymbols = "false"
             supportsJPhoneMultiMediaAttributes = "false"
             maximumRenderedPageSize = "2000"
             requiresSpecialViewStateEncoding = "false"
             requiresNoBreakInFormatting = "false"
             requiresLeadingPageBreak = "false"
             supportsQueryStringInFormAction = "true"
             supportsCacheControlMetaTag = "true"
             supportsUncheck = "true"
             canRenderEmptySelects = "true"
             supportsRedirectWithCookie = "true"
             supportsEmptyStringInCookieValue = "true"
             cachesAllResponsesWithExpires = "false"
             requiresNoSoftkeyLabels = "false"
             defaultSubmitButtonLimit = "1"
            
             supportsBold = "false"
             supportsItalic = "false"
             supportsFontSize = "false"
             supportsFontName = "false"
             supportsFontColor = "true"
             supportsBodyColor = "true"
             supportsDivAlign = "true"
             supportsDivNoWrap = "false"
             supportsCharacterEntityEncoding = "true"

             isMobileDevice="false"
</browserCaps>

 


具体属性的意思可以考试MSDN:设备功能列表
ms-help://MS.MSDNQTR.2003FEB.2052/mwsdk/html/mwlrfDeviceCapabilitiesTable.htm

但这样将给您在需要IE调试时带来很大的不便
下面代码将能解决IE和模拟器同时高度的问题(同样将下面代码加入system.web节点中)



 

代码
<browserCaps>
<result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<use var="HTTP_USER_AGENT"/>
<filter>
<case match="Unknown" with="%{browser}">
preferredRenderingType 
= "wml11"
preferredRenderingMime 
= "text/vnd.wap.wml"
preferredImageMime 
= "image/vnd.wap.wbmp"
type
=Unknown
</case>
</filter> 
</browserCaps>

 

2.链接:
在同一个aspx文件,使用Link控件的,#FORM来切换不同Form时在 OPenWave 5.0测试会出现错误!
建议在程序通过ActiveForm来做
3.乱码:
     如果在开发过程出现乱码,通过修改Web.Config
     <globalization
            requestEncoding="gb2312"
            responseEncoding="gb2312"
    />
4.取消移动设备缓存:

 

   Page.Response.Expires = -1;
    Response.CacheControl
= "Public";


5.重定向
重定向通过
RedirectToMobilePage函数
不过使用过程中可能会出现一些问题
建议用Link控件来代替

posted on 2010-04-19 14:08  Rich.T  阅读(519)  评论(0编辑  收藏  举报