最近在项目中遇到一个棘手问题,在IE10中,一些图片按钮点了毫无反应,其他浏览器(包括IE9)都正常;查看后台,发现如下异常信息:
Input string was not in a correct format.
stack: 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.WebControls.ImageButton.System.Web.UI.ipostBackDataHandler.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)
Google了一下,被证实是IE10 在.Net 4.0下的Bug,原因是IE10下,ToolKitScriptManager不能正确的识别UpdatePanel里的ImageButton的ID,解决方法有三个:
1) 用LinkButton+图片的方式替换ImageButton
2) 安装.Net 4.5框架
3)取消ImageButton的异步回传:
ToolkitScriptManager tkt =(ToolkitScriptManager)Master.FindControl("ToolkitScriptManager");
tkt.RegisterPostBackControl(ImageButton); 或者 设置UpdatePanel的 “PostbackTigger”
新闻热点
疑难解答