OnSelectedIndexChanged not firing in production -

2019-08-06 03:27发布

问题:

I have a 4.0 .NET site. I have the following element:

 <asp:DropDownList ID="ddlCounty" Width="250" AutoPostBack="true" runat="server"
 OnSelectedIndexChanged="ddlCounty_SelectedIndexChanged" />

This works when running locally in all browsers. Meaning, it hits the ddlCounty_SelectedIndexChanged function. In production, it works with all browsers, other than IE 11. In IE 11, it does not throw any JS errors, but never hits the server when the dropDownList is changed.

I saw this fix: IE 10 Fix, which added 2 App_browser files to my project. I tried this, but it did not work. Furthermore, I have verified that it works correctly in IE 10.

So basically, this issue only occurs in IE 11 (non compatibility mode).

Anyone have an idea of what I should try next?

EDIT: additional code that was request:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

回答1:

I've had this problem with IE (I think all versions as IE is horrible). Try clearing all cookies and browser history. You might need to change the settings. What I did to fix this issue was adding this line of code in the behind in the Page_Load.

Response.CacheControl = "No-cache";

Caching is basically IE's try at being quick. As far as I know, IE is the only browser that caches and this has caused browser problems only in IE. Try those steps and see if you have any luck.

EDIT: I just saw that you are using an update panel. Not sure if you have tried to use a trigger or not. This is how I have done mine..

<trigger>
<asp:AsyncPostBackTrigger ControlID="ddlCounty" EventName="SelectedIndexChanged" />
<trigger>

Or you can do it behind code..

UpdatePanel1.Triggers.Add(new AsyncPostBackTrigger()
{
    ControlID = ddlCounty.UniqueID,
    EventName = "SelectedIndexChanged",
});

But I'm just throwing ideas out there. This is one thing I'd try to see if it's a possible work around. No promises.



回答2:

I am having the same issue, event for dropdown,checkbox not firing only in IE11,
that too works fine if i chagnes F12 IE console UserAgentString to IE10

Refer this Hotfix for IE11, do as mentioned in that link, it will fix this issue
https://stackoverflow.com/a/20422240/2089963



回答3:

I ended up just installing .NET 4.5 on the server (did not change the version the site was using) and the issue went away.