Friday, January 25, 2013

How to maintain the current scroll position across postbacks in Asp.Net?

It might sometimes happen that when you submit a page you want that the scroll position of the page remain the same. So how do you do that, in Asp.Net?

First I thought about some javascript code. Well you don't need some extra js functions when Asp.Net has a built in property.

Well, in order to keep scroll position of the page the same after submit you have to set in page declaration MaintainScrollPositionOnPostback  property to "true".

As I said in order to maintain the current scroll position across postbacks you can do this:
<%@ Page MaintainScrollPositionOnPostback="true" %>

Regards.

No comments:

Post a Comment