Wednesday, March 30, 2011

AjaxControlToolkit vs. FF4&IE9

If you're using AjaxControlToolkit for your ASP.NET applications, maybe you have noticed several problems with new versions of browsers. Some problems with Internet Explorer 9 can be solved by switching the browser to compatibility mode by adding following line to the page header
<meta http-equiv="X-UA-Compatible" content="IE=8" />
Problem with Firefox 4 was an AsyncFileUpload control causing the JS error "Index or size is negative or greater than the allowed amount" which caused some problems with the remaining JS code on the page. Some guys have noticed, that the control is rendering it's id tag twice. It seems to me, that this wasn't the problem (as I have fixed this issue, but the aforementioned error was still there). The code which caused the error looked like some trivial width setting (Firefox-specific), so I've put it in the try/catch block and hoped for the best. And it worked for me.

On the following link you will find a compiled binaries of the AjaxControlToolkit (for the .NET Framework 3.5, which I'm using) which may correct this problem. But don't forget - there is no guarantee, this will work for you and that it will not break some other feature. You're downloading the following file on your own risk.


Hopefully, the authors of the toolkit will provide a complete fix soon.

If you want to compile this update on your own (for example for the .NET 4), the changes I've made are: try/catching the suspicious block (line 187) in AsyncFileUpload.pre.js and removing redundant id attribute of the HTMLInputFile in AsyncFileUpload.cs in the OnPreRender method.