Easy Way To Maintain Div Scroll Position On Postback

There are numerous ways to maintain scroll position on a postback that all involve javascript coding. Unfortuantely, it always seems like they don't work in the situation I need. Well, the other day, I found a solution that had been right in front of my nose.

I was working on a page where I wanted a list of people on the left and the details for the selected person on the right. The list was inside a scrolling div so they'd be able to scroll the list to find the individual.  Everything was wrapped in an UpdatePanel  and I had everything set up right. However, when a postback occurred -- boom -- back to the top of the div.

My solution was two UpdatePanels. One inside my scrolling div and the other holding the DetailsView. The UpdateMode is set to Always for both so when the update fires in one, it also fires in the other. Since UpdatePanel is inside the scolling div, the div (and its current scroll position don't update).

Viola, a scrolling div that maintains position without any code.

Technorati Tags: ,,

Comments

Popular posts from this blog

Windows 8 Keyboard Shortcuts

Get Asp.Net Profile properties from Sql

Migrating Legacy Apps to the New SimpleMembership Provider