vb.net WebForm_DoPostBackWithOptions 未使用 chrome 定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23184579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:25:51  来源:igfitidea点击:

WebForm_DoPostBackWithOptions is not defined using chrome

asp.netvb.netgoogle-chrome

提问by brad

On one of my pages, my dynamic links work fine in IE10 but do not work in either Chrome or via Explorer on my Windows phone. In Chrome I get the "WebForm_DoPostBackWithOptions is not defined" when I try to click on any of the dynamic links. I've done a lot of research, and have tried to modify the settings for the ISAPI filters in the Handler Mappings in IIS 8, but that didn't work. Please help. I'm stumped.

在我的一个页面上,我的动态链接在 IE10 中运行良好,但在 Chrome 或 Windows 手机上的资源管理器中不起作用。在 Chrome 中,当我尝试单击任何动态链接时,我得到“未定义 WebForm_DoPostBackWithOptions”。我进行了大量研究,并尝试修改 IIS 8 中处理程序映射中 ISAPI 过滤器的设置,但这没有用。请帮忙。我难住了。

Update: This also does not work in Firefox. It seems the dynamic links on this page work only in IE10. The links are being generated from my codebehind. The strange this is that on the other pages the links are generated differently with the javascript on the href being different, yet I'm creating the anchors in the codebehind exactly the same way.

更新:这在 Firefox 中也不起作用。此页面上的动态链接似乎仅适用于 IE10。链接是从我的代码隐藏生成的。奇怪的是,在其他页面上,链接的生成方式不同,href 上的 javascript 不同,但我在代码隐藏中以完全相同的方式创建锚点。

Here's code for a "bad" anchor:

这是“坏”锚点的代码:

    Dim anchName As New HtmlAnchor
anchName.ID = "bcrasodiuhf" & foo
AddHandler anchName.ServerClick, AddressOf HandleNameClick
anchName.Attributes.Add("style", "font-weight: bold; font-size: 14px;")
anchName.Attributes.Add("for", foo)
anchName.InnerText = foo

And the "bad" result:

和“坏”的结果:

<a id="MainContent_bcrasodiuhf1" **href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBac…0$MainContent$bcrasodiuhf1", "", true, "", "", false, true))**" for="1" style="font-weight: bold; font-size: 14px;"></a>

Here is a "working" anchor:

这是一个“工作”锚点:

    Dim ancJoe As New HtmlAnchor
    ancJoe.ID = "pjancJoe" & foo
    AddHandler ancJoe.ServerClick, AddressOf HandleJoeClick
    ancJoe.InnerText = joe.Title
    ancJoe.Attributes.Add("style", "font-size: 150%;")
    ancJoe.Attributes.Add("jn", foo)
    ancJoe.Attributes.Add("for", foo)
    ancJoe.Attributes.Add("action", "actionA")  

And the "working" result:

和“工作”结果:

<a id="MainContent_pcancJoe19416" **href="javascript:__doPostBack('ctl00$MainContent$pcancJoe19416','')"** action="actionA" for="194" jn="foo foo" forc="16" style="font-size: 150%;"></a>

回答by user2772146

The respective JS code (i.e. WebForm_DoPostBackWithOptions(options)) is a built-in part and is linked dynamically. A proper URL is being generated by ScriptManager of the page.

各自的JS代码(即WebForm_DoPostBackWithOptions(options))是一个内置的部分,并且是动态链接的。页面的 ScriptManager 正在生成正确的 URL。

Considering you've mentioned you're using URL Rewrite, try checking whether URLs like WebResource.axd?d=XXX are not being ignored/re-wrote.

考虑到您已经提到您正在使用 URL 重写,请尝试检查 WebResource.axd?d=XXX 之类的 URL 是否没有被忽略/重写。

Also, it might worth to look at IIS Handlers Mapping configuration to ensure .axd resources are mapped to the standard ISAPI module handler.

此外,可能值得查看 IIS 处理程序映射配置,以确保 .axd 资源映射到标准 ISAPI 模块处理程序。

回答by Varinder Singh

There is a bug in the browser definition files that shipped with .NET 2.0 and .NET 4, namely that they contain definitions for a certain range of browser versions. But the versions for some browsers (like IE 10) aren't within those ranges any more. Therefore, ASP.NET sees them as unknown browsers and defaults to a down-level definition, which has certain inconveniences, like that it does not support features like JavaScript.

.NET 2.0 和 .NET 4 附带的浏览器定义文件中存在一个错误,即它们包含特定范围的浏览器版本的定义。但是某些浏览器(如 IE 10)的版本不再在这些范围内。因此,ASP.NET 将它们视为未知浏览器并默认为下层定义,这具有一定的不便,例如不支持 JavaScript 等功能。

Fortunately,A hotfix is available for .NET Framework 4.0

幸运的是,一个修补程序可用于 .NET Framework 4.0

https://support.microsoft.com/en-gb/kb/2600088

https://support.microsoft.com/en-gb/kb/2600088

You can read more about this issue on Scott Hansellman's blog

您可以在 Scott Hansellman 的博客上阅读有关此问题的更多信息

http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx

http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx

回答by sino

I had (almost ) same problem , and it was fixed by reinstalling .Net Framework on the IIS

我有(几乎)同样的问题,它是通过在 IIS 上重新安装 .Net Framework 来解决的

回答by Augis

Try to set causesValidation=false for the button

尝试为按钮设置原因验证=假