ASP.NET: how to stop page from jumping when using AutoPostBack?

Sara picture Sara · Dec 15, 2010 · Viewed 9.2k times · Source

I'm using ASP.NET, and in a Wizard control I have radio buttons where if "Yes" is selected, a panel is shown, but if "No" is selected, the panel is hidden. I have MaintainScrollPositionOnPostBack set to True, though the ActiveStepChanged event changes it to False so that when you click Next to see the next Wizard step, it will start at the top of the page. The problem is, after clicking Next, the first time you click on a radio button it jumps to the top of the page (the page retains its position any time you click a radio button after the first time). How do I stop it from jumping the first time?

Answer

XtremeBytes picture XtremeBytes · Dec 15, 2010

Set Page.MaintainScrollPositionOnPostBack = true to maintain the current screen position on Postback.

This is easier than trying to do this yourself through JavaScript or whatever means.