Asp.Net,DropDownList的,的AutoPostBack和谷歌Chrome [英] Asp.Net, DropDownList, AutoPostBack and Google Chrome

查看:279
本文介绍了Asp.Net,DropDownList的,的AutoPostBack和谷歌Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的asp.net页面(框架3.5)和一个UpdatePanel了一系列的DropDownList的我想asyncronously填充。所有的,但不是在Chrome浏览器的所有主流浏览器(歌剧,Safari浏览器,IE6,IE7,FF3)的罚款。

I've a simple asp.net page (framework 3.5) and an UpdatePanel with a series of dropdownlist I want to populate asyncronously. All works fine in all major browsers (Opera, Safari, IE6, IE7, FF3), but not in Chrome.

镀铬似乎忽视了SelectedIndexChanged事件谁曾使非同步的要求。

Chrome seems to ignore the SelectedIndexChanged event who had to make the asynch request.

任何人都知道一个简单的解决方法呢?
谢谢!

Anyone knows a simple workaround to this? Thanks!

编辑:更多信息

正如我所说的亚当拉塞克,点击到一个asp后的UpdatePanel刷新:它内部的按钮,但它不与下拉的的SelectedIndexChanged 事件工作。

As I say to Adam Lassek, the updatepanel refresh after the click to an asp:Button inside of it, but it doesn't work with the dropdown's SelectedIndexChanged event.

在UpdatePanel设置,如:

The updatepanel is set like:

<asp:UpdatePanel ID="updPanel" runat="server" UpdateMode="Always" ChildrenAsTriggers="true">

无需触发指定,dropdows有集的AutoPostBack =真正的

更新:(和重新标记)

尝试几次后,我发现这是不是在UpdatePanel的问题,但似乎下拉列表的AutoPostBack不能正常工作,甚至在不用的ScriptManager和UpdatePanel的页面...
我敢肯定,这是只涉及这个项目的一个问题,因为如果我从头开始一个新的网站和复制的这种结构,在Chrome中正常工作?
我试图逐步撤销所有其他的东西,在原项目准确地找到什么问题。

After a few attempts I discover that it isn't a problem of the UpdatePanel, but it seems that the AutoPostback of dropdowns doesn't work properly, even in pages without ScriptManager and UpdatePanel... I'm sure that it is a problem concerning only this project, because if I start a new WebSite from scratch and replicate the structure of this, works fine in Chrome... I'm trying to remove step by step all the other things in the original project to find exactly what's the problem.

如果任何人有一些想法的同时...

If anyone has some ideas in meantime....

推荐答案

有一个已知不兼容的 Ajax.NET Chrome浏览器&安培; 的Safari 3

There is a known incompatibility with Ajax.NET and Chrome & Safari 3.

小,快速测试可欺骗性,因为它会出现正常工作与现有Ajax.NET库是。这是因为它管理执行第一 Ajax请求和结尾时失败,所以只有当您尝试执行第二阿贾克斯的行动,你会发现它已经失败。如果你把一个的UpdateProgress 您的网页上的控制,你会发现,在第一次请求之后,您的的UpdateProgress 控制不会disapppear。

Small, quick tests can be deceptive because it will appear to work fine with the existing Ajax.NET library as is. This is because it manages to perform the first Ajax request and fails when that ends, so only when you try to perform the second Ajax action will you notice it has failed. If you put an UpdateProgress control on your page, you'll notice that after the first request your UpdateProgress control won't disapppear.

幸运的是,有一个答案!

Luckily, there is an answer!

最近有一个伟大的职位提出了详细说明做什么,你可以在这里找到:

Recently there was a great post put up detailing what to do which you can find here:

<一个href=\"http://blog.turlov.com/2009/01/aspnet-ajax-compatibility-patch-for.html\">http://blog.turlov.com/2009/01/aspnet-ajax-compatibility-patch-for.html

它的一般要点是,无论Chrome和Safari 3自我报告为的WebKit在他们的userAgent字符串

The general gist of it is that both Chrome and Safari 3 report themselves as WebKit in their userAgent strings.

您需要在添加JavaScript的一点点帮助Ajax.NET框架承认基于WebKit浏览器,看起来像以下内容:

You need to add a little bit of javascript in to aid the Ajax.NET framework in recognising WebKit based browsers that looks like the following:

if (typeof(Sys.Browser.WebKit) == "undefined") {
    Sys.Browser.WebKit = {};
}

if (navigator.userAgent.indexOf("WebKit/") > -1 ) {
    Sys.Browser.agent = Sys.Browser.WebKit;
    Sys.Browser.version = 
        parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
    Sys.Browser.name = "WebKit";
}

您需要在添加到JavaScript文件,并引用它在的ScriptManager

You need to add that to a javascript file and reference it in your ScriptManager:

<asp:ScriptManager ID="ScriptManager1" runat="server">
    <Scripts>
        <asp:ScriptReference Path="~/assets/javascript/WebKit.js" />
    </Scripts>
</asp:ScriptManager>

请注意,你可以保持在 WebKit.js 在装配和参考,通过使用类似下面的标签的ScriptReference:

Note that you can keep the WebKit.js in an assembly and reference that by using a ScriptReference tag similar to this:

<asp:ScriptReference Assembly="Scripts" Name="Scripts.webkit.js" />

一旦你完成了这一切,如果在所有可能停止使用WebForms和Ajax.NET和使用MVC和jQuery:)

Once you've done all that, if at all possible stop using WebForms and Ajax.NET and use MVC and jQuery :)

这篇关于Asp.Net,DropDownList的,的AutoPostBack和谷歌Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆