RSS 2.0
# Thursday, April 16, 2009

I spent quite a bit of time researching and testing various solutions in trying to preserve focus on the dynamically created control causing a postback in .Net, but nothing seemed to work, most likely due to the very dynamic nature of the page I was creating.

After thinking about what I was really trying to accomplish, I came to the realization that I was not so much concerned about maintaining focus as I was concerned about maintaining the scrolling position of the page.  After about 30 seconds of searching, I discovered a handy one-liner that solved all my problems.

Adding MaintainScrollPositionOnPostBack = True to Page_Load takes care of all of this.  So, no matter how long your page is, adding this one line of code to your page will preserve scroll location on post backs.

Thursday, April 16, 2009 6:14:40 AM (Mountain Standard Time, UTC-07:00)  #    Comments [0] -

Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Categories
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
GeekzRule.com
Sign In
Statistics
Total Posts: 12
This Year: 0
This Month: 0
This Week: 0
Comments: 0
Themes
Pick a theme:
All Content © 2010, GeekzRule.com
DasBlog theme 'Business' created by Christoph De Baene (delarou)