问题描述
我有一个简单的页面,它的结构如下(伪代码):
I have a simple page, it's structure is as follows (pseudo code) :
<aspx page>
<ascx control>
<asp:dropdownlist id="dd1" autoPostback=true />
<asp:dropdownlist id="dd2" />
</ascx control>
</aspx page>
在任何桌面浏览器中,dd1 回发并触发SelectedIndexChanged"服务器事件.然而,在 iPhone safari 或 iPhone webview 中,不进行回发.我知道这一点是因为没有显示网络活动指示器,并且我已经将调试器连接到捕获所有服务器端事件的站点,并且它永远不会被命中.有时,大约每 2 小时一次,回传确实会在 iphone 上工作,但极少且间歇性地发生.
In ANY desktop browser, dd1 posts back and the "SelectedIndexChanged" server event is fired. However in the IPhone safari or an IPhone webview, no postback is done. I know this because no network activity indicator is shown and I've hooked a debugger to the site that catches all serverside events and it is never hit. Sometimes, about once every 2 hours, the postback DOES work on the iphone, but extremely rarely and intermittently.
Dd1 是一个日期下拉列表,它加载一个时间段下拉列表,该下拉列表取决于日期下拉列表中的所选项目.这种形式在很多地方重复使用,我不想改变基本结构,除非这是最后的努力.
Dd1 is a date dropdown that loads a time slot drop down that is dependent on the selected item in the date dropdown. This form is re-used in many places and I don't want to change the basic structure unless it's a last ditch effort.
在 Safari 设置中启用了 Javascript.
Javascript is enabled in safari settings.
够简单了吧?我想弄清楚如何在 webview 上调试 javascript 错误,但我想知道是否有人知道造成这种行为的奇怪之处.
Simple enough right? I'm trying to figure out how to debug javascript errors on a webview, but I was wondering if anyone knew what oddity it was that created this behavior.
推荐答案
IPhone UIWebView 的用户代理不被 ASP.NET 4.0 识别,所以 asp.net 作为默认的页面的 Downlevel 版本不包括 javascript.iphones webview 用户代理是:
The user agent of the IPhones UIWebView was not recognized by ASP.NET 4.0, so asp.net served up as a default, the Downlevel version of the page which included no javascript. The iphones webview user agent was:
Mozilla/5.0(iPhone;U;CPU iPhone OS 4_3_5,如 Mac OS X;en-us)AppleWebKit/533.17.9(KHTML,如 Gecko)Mobile/8L1
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8L1
为了避免这种情况发生,我将页面的ClientTarget"属性更改为UpLevel",它绕过了试图找出浏览器功能的 asp.net,只提供Uplevel"版本的 javascript 和所有内容.
To avoid that happening I changed the "ClientTarget" property of the page to "UpLevel" which bypasses asp.net trying to figure out the browser capabilities and just serves up an "Uplevel" version javascript and all.
我的页面 Page_Load 中的解决方案:
Solution in my Page's Page_Load:
Me.ClientTarget = "uplevel"
Me.ClientTarget = "uplevel"
或
this.ClientTarget = "uplevel";
this.ClientTarget = "uplevel";
这篇关于UIWebview 和 iPhone 内容不回发(ASP.NET 浏览器功能问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!