gpt4 book ai didi

javascript - IE10 发送带小数(浮点值)的图像按钮单击坐标导致 ParseInt32 FormatException

转载 作者:行者123 更新时间:2023-12-01 11:34:32 25 4
gpt4 key购买 nike

似乎 ASP.NET 4.0 不准备处理由 Internet Explorer 10 触发的 ImageButton 事件。问题是 IE10 将图像点击坐标作为 double 值(带小数)发送,而 ASP.NET 尝试将它们解析为整数,呈现以下类型的错误:

System.Web.HttpUnhandledException (0x80004005): 
Exception of type 'System.Web.HttpUnhandledException' was thrown.
---> System.FormatException: 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)
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.members_addtocartlogin_twostep_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\932deaba\63ff7eeb\App_Web_MyPage.aspx.28424a96.oraym_un.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

谷歌搜索,有人建议强制 IE10 在兼容性 View 中运行。但是,添加元标记 <meta http-equiv="X-UA-Compatible" content="IE=10" />解决不了任何问题;并添加 <?xml version="1.0" encoding="UTF-8">之前 <!DOCTYPE>也不行。

有什么解决办法吗?我可以使用 Javascript 捕获点击事件并以某种方式删除小数吗?

注:升级到 Framework 4.5 并重新编译修复了该错误。无需更改运行时版本,因为它仍然是 4.0。

最佳答案

.NET CLR 2.0 和 4.0 有修补程序,如 this blog entry by Scott Hanselmann 中所述:

What the fixes do is update the ie.browser and firefox.browser files in \Windows\Microsoft.NET\Framework\<version>\Config\Browsers with new and future-proofed versions of these browser definitions. Nothing else is affected.



.NET 4
  • http://support.microsoft.com/kb/2600088

  • .NET 2.0
  • http://support.microsoft.com/kb/2600100适用于 Win7 SP1/Windows
    服务器 2008 R2 SP1、Windows Vista/Server 2008、Windows XP/Server 2003
  • http://support.microsoft.com/kb/2608565适用于 Win7/Windows 服务器
    2008 R2 RTM

  • 或者,有一个基于客户端的 javascript 补丁(最初作为解决方法发布在 Connect item with bug ID:755419 上):
    $(function () {
    // Patch fractional .x, .y form parameters for IE10.
    if (typeof (Sys) !== 'undefined' && Sys.Browser.agent === Sys.Browser.InternetExplorer && Sys.Browser.version === 10) {
    Sys.WebForms.PageRequestManager.getInstance()._onFormElementActive = function Sys$WebForms$PageRequestManager$_onFormElementActive(element, offsetX, offsetY) {
    if (element.disabled) {
    return;
    }
    this._activeElement = element;
    this._postBackSettings = this._getPostBackSettings(element, element.name);
    if (element.name) {
    var tagName = element.tagName.toUpperCase();
    if (tagName === 'INPUT') {
    var type = element.type;
    if (type === 'submit') {
    this._additionalInput = encodeURIComponent(element.name) + '=' + encodeURIComponent(element.value);
    }
    else if (type === 'image') {
    this._additionalInput = encodeURIComponent(element.name) + '.x=' + Math.floor(offsetX) + '&' + encodeURIComponent(element.name) + '.y=' + Math.floor(offsetY);
    }
    }
    else if ((tagName === 'BUTTON') && (element.name.length !== 0) && (element.type === 'submit')) {
    this._additionalInput = encodeURIComponent(element.name) + '=' + encodeURIComponent(element.value);
    }
    }
    };
    }
    });

    关于javascript - IE10 发送带小数(浮点值)的图像按钮单击坐标导致 ParseInt32 FormatException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13299685/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com