Nikolaos Kantzelis ASP.Net Blog

This blog will focus on ASP.NET Framework

Sponsors

About Me

Great Blogs

Maintain scroll position in ASP.NET

One of the most common questions I get is " How to maintain the scroll position-location when a postback occurs in our ASP.NET application? "

A lot of times when  we click on a e.g a button in our application and a postback occurs, our application "loses" its scroll position.

The default behaviour is to go back to the top of the page.

There is a very nice feature in ASP.NET that enables us to maintain the scroll position in ASP.NET.

The name of this attribute is MaintainScrollPositionOnPostBack.

We can set the  MaintainScrollPositionOnPostBack="true"

we can do that within the Page directive e.g

<% Page Language ="C#"  MaintainScrollPositionOnPostBack="true" %>

So now the browser remembers where it was before the post back occured and knows how to keep track of the scroll position.

This is of course achieved with client-side Javascript code that it is injected into the page for us.

So if you go to View -->Source in your browser window, you will see the generated Javascript code.

Hope it helps!!!!

 

Comments

Maintain scroll position in ASP.NET - Nikolaos Kantzelis-ASP.NET MVP said:

Pingback from  Maintain scroll position in ASP.NET - Nikolaos Kantzelis-ASP.NET MVP

# March 6, 2010 4:04 PM

hotel escorts said:

It was certainly interesting for me to read that post. Thank author for it. I like such themes and everything connected to them. I definitely want to read a bit more on this blog soon.

Avril Smith

# May 16, 2010 3:46 PM

east indian escort said:

Truly cool article to track it to my thinking. BTW, why don't you submit it to social bookmarks? It might bring much traffic here.

# June 2, 2010 12:16 AM

London escort service said:

Really good article to read it to my mind. BTW, why don't you submit this post to social bookmarking sites? That can bring lots of traffic here.

# June 19, 2010 6:24 AM

Kiev escort agency said:

Cool story you got here.

It would be great to read something more concerning that theme.

Thnx for posting this material.

With best regards Lina!

# September 19, 2010 2:17 AM

Chris said:

Really helped!! Thanx!

# October 13, 2010 11:16 AM

Obsepsibeks said:

I recently found this website that I want to share with everyopne as they were a great help when I was

working on a recent project. I needed to know how to do some stuff in PHP and they were able to provide

a tutorial sepcifically tailored to my needs. It was very helpful.

<a href=http://teamtutorials.com>TeamTutorials</a>

I recommend you hit them up and check them out if you need assistance.

# February 20, 2011 10:06 AM

avrail said:

thanks a lot great article

# March 1, 2011 2:32 AM

hooher tod said:

Yes there should realize the reader to RSS my feed to RSS commentary, quite simply

# September 5, 2011 3:51 PM

Kash said:

Very helpful. Thanks

# March 8, 2012 3:02 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)