SmartNavigation to maintain scroll position across postbacks

Smart navigation is deprecated in Microsoft ASP.NET 2.0 and is no longer supported by Microsoft Product Support Services. This article describes how to implement the smart navigation features in ASP.NET 2.0.

For more information check http://support.microsoft.com/kb/913721

Thanks to Deepak for posting this in the comments. 

This article describes about using the Smart Navigation property to maintain the scroll position of pages across postbacks.

All of us know that asp.net controls postback to the server and hence the page is reloaded everytime an event is triggered.

Supposing we have a very long page with lots of controls. A user is in the middle of the page and triggers an event (say click event), which causes the page to postback. Then the page will be reloaded and the position would go to the top.

This could be particularly annoying if the user has to scroll down long and repetitively.

To avoid this, ASP.NET provides the SmartNavigation property for the page which takes care of the scroll position.

SmartNavigation also avoids the flickering of the page when the page is reloaded.

It can be enabled by simply setting its value to true in the page directive, as follows:-

<%Page smartNavigation="True" %>

Alternatively, it can be specified as a global setting in the web.config as follows:-

<configuration>
<system.web>
<pages smartNavigation="true"/>
</system.web>
</configuration>

This would apply for all the pages that fall under the web.config's settings.

This is a wonderful mechanism particularly if you have lengthy pages and repetitive server side interactions.

This works only for Internet Explorer browsers and for Netscape, it is simply turned off automatically.

Another issue that may arise is when using javascript and dhtml scripts as they will not be rendered again while using smartnavigation.

Cheers !!!

Print | posted on Monday, April 25, 2005 7:52 AM

Comments on this post

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
Thank you very much. I tried altering some autoscroll scripts I found on the web, but figured there had to be an easier way to do it, without the need to register another client script.
Left by Willie Williams on Jul 18, 2005 7:25 PM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
This gave me that what i have expected. previously i did this but i forgot the and found from your URL. Thank you very much.
Left by Sathya on Mar 14, 2006 10:50 PM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
Thanks that was very useful. But the font size changes. Is there any way to retain?
Left by TIG on Nov 07, 2006 10:38 AM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
Thank U very much
Left by Mohan on Dec 02, 2006 4:15 AM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
"Another issue that may arise is when using javascript and dhtml scripts as they will not be rendered again while using smartnavigation"
can you please explain this to me, i mean to say that I am very well aware of dhtml and javascript but can you tell me, how critical it can be and why is that so
Left by arfeen on Aug 07, 2007 5:15 PM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
It doesnot work for me. I tried modifying the weconfig file. Please help me out.
Thanks
Left by Chaitanya on Feb 14, 2009 3:32 AM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
Smart navigation is deprecated in Microsoft ASP.NET 2.0 and is no longer supported by Microsoft Product Support Services. See KB: http://support.microsoft.com/kb/913721 for complete details.
Left by Deepak on Mar 25, 2009 1:51 AM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
ok
Left by Varun on Jun 25, 2009 9:01 AM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
you please explain this to me, i mean to say that I am very well aware of dhtml and javascript but can you tell me
Left by mario oyunları on Sep 21, 2009 10:37 AM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
Thanks for the information, now it does exactly as I expected :)
Left by Cam on Dec 26, 2009 11:45 AM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
Smart navigation is no longer in use from .net 2.x version. But the same can be implemented by other .net features.
Left by Anuj Tripathi on Jan 26, 2010 6:59 AM

# re: SmartNavigation to maintain scroll position across postbacks

Requesting Gravatar...
Thanks for the update Deepak, was wondering why I wasn't getting anywhere...
Left by worldcup on Mar 31, 2010 7:51 AM

Your comment:

 (will show your gravatar)