Tim Blog

坑爹的ImageButton

同事离职,交接到我手上一个web应用。本机上试用了一下没有问题。这两天发布到IIS上,问题大事儿了。

服务器是win2003+IIS6 客户端是win8+ie10

保存操作提示

image

但是在IE其他版本以及chrome等浏览器下没有这个问题。

一开始以为是程序的bug,到处添加debug信息排错。最后发现是在pageinitcomplete之后,pagepreload之前。应该是控件加载时的错误。

比较了在ie9和ie10提交的信息的差别,

ie10下:

[ctl00$MainContent$ButtonSave.y]:8.6899995803833  

[ctl00$MainContent$ButtonSave.x]:42.279998779296875     

ie9下:

[ctl00$MainContent$ButtonSave.y]:7     
[ctl00$MainContent$ButtonSave.x]:36  

可以看到提交了按钮的坐标,ie10是double的,ie9下是int的。

exception message: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Web.UI.WebControls.ImageButton.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Imagebutton控件将字符转换为Int,ie10的肯定报错了。

 

问题原因找到了,具体解决方法:

1.升级为.net 4.5

2.设置IIS,增加 X-UA-Compatible 为IE9

3.安装微软的更新

4.去掉Imagebutton,改为 a+css

 

懒得折腾,直接第二种方法先凑合吧。

坑爹的ImangeButton

MVC4都有了,还用这么陈旧的 web form 来搞,哎……

posted @ 2013-07-18 16:21  流沙  阅读(267)  评论(0编辑  收藏  举报