473,394 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

ASP.Net Ajax and Browser Scroll Positioning

2
Hi,

I have a problem with a current project and the scroll position.

I have an AJAX enabled website using Visual Studio 2005 and ASP.Net 2.0.

The project also uses masterpages.

On the page in question, there is a search section in an AJAX update panel, situated on the left hand side. Upon submitting criteria and pressing a button, the results are displayed on the right hand side of the page.

On the right hand side of the page, there is another AJAX Update Panel. Within this Ajax Update Panel there are 2 standard asp.net panels. Only 1 of these two standard asp.net panels is ever displayed at any one time. The first of the standard panels is used to display the list of results.

When a user selects an item from the list of results to view in full detail, the first standard asp.net panel is made Invisible, and second standard asp.net panel is then made visible, which displays the details of the selected item.

So, the way the two standard asp.net panels (that are contained with the AJAX update panel) work is like a master-detail relationship between the list of results and the details for a particular, selected item.

All of this works fine apart from one aspect.

If the user has scrolled down to an item near the bottom of the list of results, when they select the item to view and the second asp.net panel is then displayed, the browser is still in the same position. This means that the user is then looking half-way down the details, which is obviously not acceptable.

Note: when I say “scrolled down” I mean using the browser scroller – no DIV scrollers are used etc.

What I want to happen is that when the asp.net panel containing the detail is displayed, the browser position should be positioned so that it is at the top of the page.

However, the user can also click a “back to results” link when looking at the details. If this is clicked, then when the panel containing the results is then displayed again, I need the browser to reposition back to where it was originally (i.e., just before the user clicked to view the details of a particular item in the results list).

I’ve looked around in some books and on the web, but the solutions I’ve found there don’t work for this scenario. Of course, we are mainly dealing here with the implications of AJAX and partial page postbacks (for the Update panel).

The site needs to work in IE6, IE7 and (ideally) Firefox.

I would appreciate any help on this because a lack of a solution might mean going right back to the drawing board.

Many thanks,
Darren
Apr 22 '08 #1
1 1741
Frinavale
9,735 Expert Mod 8TB
You should look into writing a JavaScript function that scrolls the browser back to the top once the Ajax call has ended it's request.

Look into using the PageRequestManager to execute JavaScript when the Ajax call has returned.

For example, you would add a script something like the following to your page:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     var prm = Sys.WebForms.PageRequestManager.getInstance();
  3.     prm.add_endRequest(endRequestEventHandler);
  4. //Note that the endRequestEventHandler is the name of the method that should be called to handle the event that occurs when Ajax request has completed.  This is something like a delegate.  You cannot pass parameters to this function...do not include brackets () either...it is simply the name of the function.
  5.  
  6. function endRequestEventHandler()
  7. {
  8.    //....code for scrolling goes here
  9. }
  10. </script>
  11.  
You'll have to look into how to create a JavaScript function that does the browser scrolling...


-Frinny
Apr 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be auto so that my content would be centered. ...
34
by: Marian Aldenhövel | last post by:
Hi, I am in the process of embarking on building a large web application. I wanted to seize that opportunity to learn how to use CSS and get rid of my ad-hoc approach to HTML-coding (i.e.: add...
12
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical...
8
by: Jimnbigd | last post by:
What is the recommended code to test browser type, for conditional processing in Javascript? I have seen tests for "document.all". I have seen tests for the actual browser name, or substrings in...
6
by: Lester L. | last post by:
Hello all, I've been trying for quite some time to eliminate scrollbars on my latest site; I'd be perfectly happy if only the horizontal one would go away, actually. FF and Opera have horiz....
31
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked...
5
by: toffee | last post by:
Hi, I need some pointers as I have no idea how to get started. I have a large table which pulls data from a mysql db. Because of the large number of records, it clugs up lot of memory and the...
2
by: =?Utf-8?B?VG9u?= | last post by:
Hello, I want to understand teh benefits of ajax technology. Does anyone has a good website where AJAX EXTENSIONS is worked out so I really understand it. There a 2 main questions: 1) How about...
3
by: Jonathan Wood | last post by:
I am completely new to AJAX. I have a GridView control and my client is complaining that, whenever they select a row in the grid, the page resets to the top of the page. It seems like AJAX...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.