问题
I have an ASP.NET Web Forms page that has a form in it and I load it in an <iframe>
as a popup.
In all modern browsers it works great.
In IE9 and below, however, things are weird.
One file input element failed to open the file selection dialog when clicking on its browse button.
After fixing this (with a JS trick), I saw another problem. Another button inside the form with this attribute for postback:
onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnUpload", "", true, "", "", false, false))"
..failed to invoke the code behind.
When the page loads, it hits my OnLoad() method on the server.
I have searched the whole web trying to find a solution and I have seen others having JS problems inside iframes, but nothing seemed to help. Does anyone have any idea what may be wrong here? This is clearly an IE9 problem, but how can I solve it?
UPDATE: After a few tries, I get an "Access Denied" during the form post, while I shouldn't (It is on the same domain and access should and is allowed).
UPDATE2: I have searched stuff about X-FRAME-OPTION : x-frame-option SAMEORIGIN and clickjacking in ASP.NET but doing this in my Application_BeginRequest
doesn't seem to help:
HttpContext.Current.Response.AddHeader("x-frame-options", "SAMEORIGIN");
Related questions: Get Error WebPage Access is denied in IE
UPDATE3: OK. The access denied is because I send the click to the file input by JS. IE doesn't like it. The mystery of the Browse button not working remains. Perhaps it is a Telerik problem spread to ASP.NET controls: http://www.telerik.com/forums/browse-button-doesnot-workin-ie8#rGGhp26Lm02afXkJNMwQ3g
回答1:
OK. I have finally solved this one by using the RadUpload instead of the normal Upload ASP.NET control.
来源:https://stackoverflow.com/questions/24189966/asp-net-web-forms-button-not-working-inside-iframe-in-ie9-and-below