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 !!!

posted @ Monday, April 25, 2005 7:52 AM

Print

Comments on this entry:

# re: SmartNavigation to maintain scroll position across postbacks

Left by Willie Williams at 7/18/2005 7:25 PM
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.

# re: SmartNavigation to maintain scroll position across postbacks

Left by Sathya at 3/14/2006 10:50 PM
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.

# re: SmartNavigation to maintain scroll position across postbacks

Left by TIG at 11/7/2006 10:38 AM
Gravatar
Thanks that was very useful. But the font size changes. Is there any way to retain?

# re: SmartNavigation to maintain scroll position across postbacks

Left by Mohan at 12/2/2006 4:15 AM
Gravatar
Thank U very much

# re: SmartNavigation to maintain scroll position across postbacks

Left by arfeen at 8/7/2007 5:15 PM
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

# re: SmartNavigation to maintain scroll position across postbacks

Left by Chaitanya at 2/14/2009 3:32 AM
Gravatar
It doesnot work for me. I tried modifying the weconfig file. Please help me out.
Thanks

# re: SmartNavigation to maintain scroll position across postbacks

Left by Deepak at 3/25/2009 1:51 AM
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.

# re: SmartNavigation to maintain scroll position across postbacks

Left by Varun at 6/25/2009 9:01 AM
Gravatar
ok

Your comment:



 (will not be displayed)


 
 
 
 

Live Comment Preview:

 
«July»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678