asp.NET LinkButton not working in Google Chrome

那年仲夏 提交于 2019-12-02 08:20:14
Nithesh Hebri

Add the following code to OnPreInit method of base page.

protected override void OnPreInit(EventArgs e)
{
    if (Request.UserAgent != null && (Request.UserAgent.IndexOf("AppleWebKit") > 0))  // added for compatibility issues with chrome 
    {
        this.ClientTarget = "uplevel";
    }

    base.OnPreInit(e);
}

You could try to open the JavaScript console in Chrome (Ctrl+Shift+j) and see if any errors are reported when loading the page or when clicking the buttons.

I've experienced problems with LinkButtons caused by totally unrelated JavaScript errors.

If this works in other browsers and not chrome, then you should file a bug here.

Disabling the "Chrome Toolbox (by Google)" extension fixed the issue for me. If you don't have that extension still try disabling all your Chrome extensions.

When I had the issue, my first instinct was that it was incompatible Javascript provided by ASP but then I noticed the same exact issue on certain links here at Stackoverflow.

Also worth noting is that only the left click was broken - middle clicking links still opened them in a new tab.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!