How to enable/disable MaintainScrollPositionOnPostback property  through code

Hudaje used Ask the Experts™
Hello Experts,

I have a listview in my 3.5 web page. The list view is tied to a datapager control. I also have image buttons in the listview rows that can submit the page and do some backend processing. Here is the issue: I want to enable the MaintainScrollPositionOnPostback for the page, but I don't want it to be active (or true) when the datapager pager links are clicked. I only want it to be active when the image buttons are clicked. Is this possible?

I tried to control the property by setting this.MaintainScrollPositionOnPostBack = false in my listview pageproperties change event. And then to set it to true in my image button click events. But once it is turned off (by using the data pager links), then the image button event does not seem to turn it on, even though the listview page properties event does not fire.

Is it really possible to control scrolllock page property through .cs code?
I prefer not to add custom javascript code for the scroll position, so if possible I would like to try to set this by playing with the property in the .net page.  My last resort would be to code JavaScript function for it, so any pointers to such code are also welcome.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi, I doubt that it'll be possible.

The following link shows details regarding the property and
number of posts from the community which shows where exactly this property is not
working. Just go thru over it once to gain a better understanding of using it.

Master page, multiple update panels and ajax controls altogether were making writing javascript code from the ground up a nightmare. Fortunately there is another way to achieve this. Some javascript is still needed but blends quite well with the .net code.

For anyone who is looking for the solution, here is an article from 4guysfromrolla website that explains how this can be achieved, quite easily. 

Scott Mitchell shows how to use JavaScript to reset the scroll position conditionally from server side code when the MaintainScrollPositionOnPostback property is on. This is exactly what I was looking for and is working quite well for me.
Thanks to 4 Guys From


Thanks for the info and the helpful links.  At this point  I  am pretty much certain that I'll have to do some client side JavaScript code to get this done.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial