坑爹的ImageButton

本文描述了一个web应用程序在IE10浏览器下使用ImageButton控件时出现的问题及解决方案。问题出现在从webform迁移到.NET 4.5或更高版本、调整IIS设置、安装微软更新或替换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 来搞,哎……

转载于:https://www.cnblogs.com/timothyzhong/p/3198456.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值