Question

I am having a really annoying issue where the page visibly jumps to the top and then to the previous scroll position on a postback.

Some details: I have an ASP.NET (VS 2010, .Net Framework 4.0) page that is using a set of RadioButtons in a RadioButtonList to display and hide a couple of Panels depending on which RadioButton is selected. There are also a couple of other controls on the page that cause the page to post back to the server. I have the MaintainScrollPositionOnPostback page attribute set to "true".

Functionally all of this works fine. The problem is visually the page jumps to the top when reloaded and then jumps down to the previous scroll position. But only in some browsers. I have tested this on my development machine using IE 9, Chrome and Firefox. My boss is testing it only in IE 9. On my development machine it works perfectly in IE 9 (oddly enough) but not in Chrome or Firefox. In IE the page sits there as it looked before the post back and then simply displays or hides the panel maintaining the previous scroll position the entire time. Looks great. In Chrome and Firefox, when the page reloads, it jumps to the top of the page and then jumps down to the previous scroll position and is really annoying to observe. The kicker is, on my bosses machine, she is also using IE 9. In fact it is the exact same version I am running but on her machine she is seeing the the same behavior that I am seeing in Chrome and Firefox.

I have tried adding the following meta tags, in every combination conceivable, but they have not done anything to help solve this issue.

<meta http-equiv="Page-Enter" content="Alpha(opacity=100)" />
<meta http-equiv="Page-Exit" content="Alpha(opacity=100)" />

Am I going to need to re-architect this page to use an UpdatePanel to resolve this issue or is there another way? What am I missing here?

Was it helpful?

Solution

Well . . . This is not really the answer but I solved the issue bu adding some Update Panels to the page and it works great.

I'm still curious about the issue and if someone would like to weigh in on it I'll continue to monitor this post to see what you have to say about it.

OTHER TIPS

You should consider taking advatage of a JavaScript workaround that leverages the __LASTFOCUS hidden field. It is documented in this CodeProject article:

http://www.codeproject.com/Articles/17571/Maintain-focus-between-postbacks-in-ASP-NET-al

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top