Postback behavior of dropdown in firefox

Note: I have moved to blog at my own domain, so kindly visit this post over there for recent updates or comments. http://www.imranbalouch.com/blog/index.php/2011/03/postback-behavior-of-dropdown-in-firefox/

I am not sure that either it is behavior of firefox or not but that was a strange thing that happened to me during a development.

I have a web application in ASP.NET and C#. On a page I have a drop down list, which works fine in IE. However in firefox if I click on the dropdown, it get expanded, now if i type some charcter, relevant value get selected, now if i click out side the dropdown anywhere on my page, dropdown collpased, new value is shown as selected but no post back occurs even auto post back is set to true.

I even put a client side function to call on change of value, but that also didn’t get called.

I feel like that it is behavior of firefox, caz it appears that firefox postbacks data after dropdown looses focus. on 1st click the focus is at the dropdown and on 2nd click dropdown looses focus. But the wiered thing is that in dropdown new value is being displayed to the user.

But on the other hand if we see it is a nice behavior of firefox, caz on dropdown list if autopoastback is set to true than in IE, if u move focus to dropdown and type A, first value starting with A is selected and page is post backed where as firefox waits for lossing focus so that if selected value is not your desired one than u can reach desired value and avoid extra post backs.

A way out that I found to avoid it in case of mouse usage is to capture the onclick event of dropdown in javascript and hold a value that the dropdown is opened now and capture onclick event of page and see if previous click was on dropdown and new click is not on dropdown than using dopostback, make a post back for the dropdown. I know currently its a wiered solution but right now i figured out only this way to handle it.

All is Well…

Advertisements