Click here to Skip to main content
Click here to Skip to main content

IE10 and ImageButtons

, 20 Nov 2012 CPOL
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

Comments and Discussions

QuestionToolTip should not be disappear after removing mouse pointer from that object. Pingroupargeraju17-Feb-14 0:16 
QuestionImageButtons do not work in IE10 (i m using .net framework 2.0 ) Pingroupargeraju9-Dec-13 19:17 
QuestionImageButtons do not work in IE10 (i m using .net framework 2.0 ) Pingroupargeraju9-Dec-13 19:15 
QuestionWhere does the code go? PinmemberRichard Creer17-Jun-13 5:29 
AnswerRe: Where does the code go? PinmemberArno197317-Jun-13 6:41 
QuestionThanks! PinmemberAshley van Gerven5-May-13 19:04 
Questioni have used this code in ASP.NET, VB.NET PinmemberElayaraja Ponnusamy14-Apr-13 21:11 
Questioncan't override LoadPostData PinmemberMember 99673175-Apr-13 4:04 
QuestionOverflowException PinmemberMarjaR15-Mar-13 5:01 
AnswerRe: OverflowException [modified] PinmemberMarjaR16-Mar-13 4:03 
QuestionPossible IE bug PinmemberAbdias Software21-Nov-12 17:31 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 20 Nov 2012
Article Copyright 2012 by Arno1973
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid