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.

13 comments:

spax said...

I have to give you all my thanks. Without this Firefox 4 only take de first postback on a page and update a conditional updatepanel. If i try to call again an action ff4 don´t render it.

Anonymous said...

Thank you for this post. I've been in the same kind of trouble. Now I just converted back to NET 3.5 and use your dll.
Additionaly the AsyncFileUpload Control also triggered the Script Manager's Navigate-Event with got me some problems when Enabling the History, but checking for the IsNavigating Property fixes that as well.

Anonymous said...

Thanks for your help, made the changes and recompiled this for .NET 4. Didn't have to mess around with the HTML Input Id, but try-catching the block on line 187 did the trick.

Ravi said...

Hi,

Many thanks for this post. I was also having the issue which got resolved by downloading you binaries, but now my AsynchUpload control stopped working, in AsynchUpload1_UploadComplete event AsynchUpload1.HasFile results in FALSE.

Can anybody help me in solving this issue??

Thanks in advance

SorryForMyEnglish said...

Hi Ravi, I'm happy that my post helped You. From your description I suppose that your problem is unrelated to this issue. Maybe you can test your problem in older browsers (FF3.5, IE 6/7/8) and you will see. Another possibility is to inspect the comunication between your browser and server for example using FireBug or Fiddler. You will see whether the file is transmitted and continue debugging on the server side.

Anonymous said...

For the HasFile=False issue, set PersistFile to True and ClientIDMode to AutoID in the control declaration and the HasFile should work as expected, of course YMMV

Tom said...

According to Firefox the error occurs on line 191:

this._inputFile.size = 0;

Looking at the source code it seems like they were trying to work around an issue with Firefox which presumably has now been fixed in version 4. So surely a better fix than using try/catch is to amend the conditional on the line above from:

if (Sys.Browser.agent == Sys.Browser.Firefox){

to

if (Sys.Browser.agent == Sys.Browser.Firefox && Sys.Browser.version < 4){

This worked for me.

(Of course this is an example why relying on browser detection should be avoided if possible - I'm not sure how possible it would have been in this case.)

Tom said...

Sorry, that line number is more like 187 actually - around there anyway.

Tom said...

The new version of the AJAX Control Toolkit (only released on Friday) fixes this issue:

http://ajaxcontroltoolkit.codeplex.com/releases/view/65800

Weena Jimenez said...

Thanks for your comments was as a big helping. The new version of ajaxToolKit it's working perfectly.

Sadia said...

Thank you so much by copying your mentioned dll my problem get resolved.

EDWIN DUQUE said...

you save my life. all my project was in framework 4.0, I did the downgrade with hopeless, now everything works. greetings from Colombia. sorry for my English

mohamed said...
This comment has been removed by the author.