Wednesday, June 18, 2008

ImageButtons that are DefaultButtons cause an error on Firefox 3

Ok, so suddenly with Firefox 3 I've been getting errors on some pages. They have an ajax panel (from Telerik, but I've found out this happens with other ajax libraries) that wraps a asp:Panel (with default button set to) an asp:ImageButton.

This works fine on all browsers. Except Firefox 3. It'll return an "Input String was not in a correct format." It seems on loaded of some posted data it is expecting an Int and it is a String.

I was stumped on this. Taking out the ImageButton (and just having it be a regular button) fixed the problem. Not making the ImageButton the default button for the panel fixed the problem. Taking out the ajax wrapper panel fixed the problem.

After banging my head on this for quite a while my coworker Del found the solution. It turns out that there is a weird double post-back happening, leading to much confusion. By adding:

OnClientClick="this.disabled=true;__doPostBack(this.name,'');"

To the imagebutton and everything works. The page that he found that talks about this is http://forums.asp.net/p/1121832/1757434.aspx which also gives some other solutions to the problem. Here is another link http://www.andornot.com/about/developerblog/2007/09/fix-firefox-defaultbutton-issue-with.aspx



Unfortunately, we'll probably have to go back to all of our old websites to find and fix this behavior (I've been able to reproduce it in many sites we've done that have been up (and bug free) for a while. I don't think it is necessarily a firefox 3 issue, but has more to do with timing.

Labels: , , , , , , , , , ,

3 Comments:

Anonymous Anonymous said...

Thanks Man.
Its really helped.
But i'm really nervous that such critical bug was not fixed neither FF team and MS team.
Unfortunately i can't find anything else to use to solve the problem, thus have to use OnClientClick

1:55 AM  
Anonymous Steve Newman said...

Fantastic, this was driving me crazy and I wasn't looking forward to upgrading the controls to the latest prometheus set to overcome it.

However, in my scenario I found it was occuring with all ImageButtons within RadAjaxPanels, even ones not marked as the default button. Also I found that the double postback behaviour was still present, and it was breaking my merchandise browser as it was drilling down two levels instead of one but just adding

OnClientClick="this.disabled=true;"

solved the problem for me.

Thanks again!

6:00 AM  
Blogger Jiro Feingold said...

I've run into some problems with this solution too, and had to go back to using a link button (with an image inside of it).

3:37 PM  

Post a Comment

<< Home