Click here to Skip to main content
13,045,564 members (69,699 online)
Click here to Skip to main content
Add your own
alternative version


4 bookmarked
Posted 20 Nov 2012

IE10 and ImageButtons

, 20 Nov 2012
Rate this:
Please Sign up or sign in to vote.
A fix for ImageButtons problem in IE10 when project is not 4.5


Let's discover how Microsoft introduces a new concept: pixel splitting...


For some reason, your ASP.NET 4.0 solution cannot be updated to 4.5 (that's my case). Using a lot of ImageButtons, the application now crashes in IE10 (Win8 but also Win7 preview).

After searching around, I found that the problem is caused by IE10 itself. When a user clicks on an imageButton, a NameValueCollection is created with a few key/values. Among these, we can find the coordinates of the clicked control.

But, for obscure reasons, IE10 sends this information in decimal (position of the control can be x: 18.66648424 y: 54.687142514 (???)).

ASP.NET is waiting for an integer value and logically fails when attempting to convert the string "18.66648424" into an integer.

Using the Code

I found a little fix for this by overriding "PostLoadData" method in ImageButton. So, all you need to do is to override this method with something like this:

protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
            // Control coordinates are sent in decimal by IE10 
            // Recreating the collection with corrected values            
            NameValueCollection modifiedPostCollection = new NameValueCollection();
            for (int i = 0; i < postCollection.Count; i++)
                string actualKey = postCollection.GetKey(i);
                if (actualKey != null)
                    string[] actualValueTab = postCollection.GetValues(i);
                    if (actualKey.EndsWith(".x") || actualKey.EndsWith(".y"))
                        string value = actualValueTab[0];
                        decimal dec;
                        Decimal.TryParse(value, out dec);
                        modifiedPostCollection.Add(actualKey, ((int)Math.Round(dec)).ToString());
                        foreach (string actualValue in actualValueTab)
                            modifiedPostCollection.Add(actualKey, actualValue);
            return base.LoadPostData(postDataKey, modifiedPostCollection);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

France France
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionToolTip should not be disappear after removing mouse pointer from that object. Pin
argeraju16-Feb-14 23:16
groupargeraju16-Feb-14 23:16 
QuestionImageButtons do not work in IE10 (i m using .net framework 2.0 ) Pin
argeraju9-Dec-13 18:17
groupargeraju9-Dec-13 18:17 
QuestionImageButtons do not work in IE10 (i m using .net framework 2.0 ) Pin
argeraju9-Dec-13 18:15
groupargeraju9-Dec-13 18:15 
QuestionWhere does the code go? Pin
Richard Creer17-Jun-13 4:29
memberRichard Creer17-Jun-13 4:29 
AnswerRe: Where does the code go? Pin
Arno197317-Jun-13 5:41
memberArno197317-Jun-13 5:41 
QuestionThanks! Pin
Ashley van Gerven5-May-13 18:04
memberAshley van Gerven5-May-13 18:04 
Questioni have used this code in ASP.NET, VB.NET Pin
Elayaraja Ponnusamy14-Apr-13 20:11
memberElayaraja Ponnusamy14-Apr-13 20:11 
Questioncan't override LoadPostData Pin
Member 99673175-Apr-13 3:04
memberMember 99673175-Apr-13 3:04 
QuestionOverflowException Pin
MarjaR15-Mar-13 4:01
memberMarjaR15-Mar-13 4:01 
AnswerRe: OverflowException Pin
MarjaR16-Mar-13 3:03
memberMarjaR16-Mar-13 3:03 
QuestionPossible IE bug Pin
Abdias Software21-Nov-12 16:31
memberAbdias Software21-Nov-12 16:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 20 Nov 2012
Article Copyright 2012 by Arno1973
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid