I've been tasked with cleaning up a few remaining bugs in a system that is about to go live. I spent most of last week trying to figure out this one.
A page in a site included an asp:FileUpload control. This was working fine but then suddenly stopped. When the user submitted the form the FileUpload control would be cleared and nothing happened - no postback, no file uploaded, nothing. Ah, but only in IE 7 (we didn't have 6 to test with), FireFox works fine.
So, to cut a very long story short and to save anyone else from murderous thoughts, here is the reason and solution (at least for me).
After turning on script debugging I could see an exception on the ASP.Net postback event:
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
The message displayed was htmlFile: Access Denied.
After much googling I found a few forum threads (heres one) that indicated that this was a security feature introduced in XP SP2, the idea, I think, was to prevent files being uploaded without the user knowing about it. Unfortuately none of the suggested solutions apply or work for me.
After winding back the source day by day to a version that worked I was able to determine that the inclusion of an onload event handler in the body tag of the page was the cause. Removing this fix the problem immediately.
Conslusion? Well, I think IE is thinking that the onload event handler could be doing something dodgey so it enters a hightened state of alert and locks out the upload control.
Parting Shot: Why the frac is this behaviour not documented by Microsoft and the IE team? Maybe it is and google can't find it... but I doubt that.
Heopfully you wont waste 3 days like I did trying to solve this.