I'm not the first to complain about OnSelectedIndexChanged not firing in IE, once deployed:
- OnSelectedIndexChanged not firing in production - IE 11 only
- DropDownList not firing OnSelectedIndexChanged
- ASP.Net DropDownList OnSelectedIndexChange not firing
- onChange and onSelectedIndexChanged events not firing - selectbox
- And many more.
Here's my code:
<asp:DropDownList id="MyDropDownList" runat="server">
<asp:ListItem Text="Life" Value="1" />
<asp:ListItem Text="Universe" Value="2" />
<asp:ListItem Text="Everything" Value="42" />
</asp:DropDownList >
and:
protected override void OnInit(EventArgs e)
{
MyDropDownList.AutoPostBack = true;
MyDropDownList.SelectedIndexChanged += new EventHandler(MyDropDownList_SelectedIndexChanged);
}
protected void MyDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
//lots of cool stuff
}
Now let us dig into the result HTML.
Here's with Chrome, (or IE with compatibility mode):
<select name="MyDropDownList" onchange="javascript:setTimeout('__doPostBack(...)', 0)" id="MyDropDownList">
<option value="1" selected="selected">Life</option>
<option value="2">Universe</option>
<option value="42">Everything</option>
</select>
And here it is with IE10/IE11 (without compatibility):
<select name="MyDropDownList" id="MyDropDownList">
<option value="1" selected="selected">Life</option>
<option value="2">Universe</option>
<option value="42">Everything</option>
</select>
Surprise!
The onchange
attribute is gone!
OK...
So now I know why the event isn't firing from IE.
...But why is it rendered differently?
Important detail: This only happens once deployed to server (I believe it's IIS6). Locally, it works fine.
Another important detail: Installing any sort of patch is unfortunately not an option for me.