Keeping Scroll Position over post Backs
page 2 of 3
by Justin Lovell
Feedback
Average Rating: 
Views (Total / Last 10 Days): 44018/ 37

The JavaScript
Essentially, the script listed below is the one that will save the scroll position constantly to hidden fields. The rate that the scroll position is saved is 100 times per second to ensure maximum resolution of where the user is. The script is listed below:
function SaveScrollPositions() {
   document.forms[0].StaticPostBackScrollVerticalPosition.value =
(navigator.appName == 'Netscape') ? document.pageYOffset : document.body.scrollTop;
document.forms[0].StaticPostBackScrollHorizontalPosition.value =
(navigator.appName == 'Netscape') ? document.pageXOffset : document.body.scrollLeft;
setTimeout('SaveScrollPositions()', 10);
}
SaveScrollPositions();

And, when the page has been posted back to, it then renders the following JavaScript:

function RestoreScrollPosition() {
   scrollTo(0, 400); // determined during run-time
}
window.onload = RestoreScrollPosition;

What is noteworthy on the above JavaScript is that the RestoreScrollPosition method is only called once the page has loaded. The JavaScript waits for the page to load completely so we could overcome a bug in Internet Explorer when the script attempts to scroll the page (via the scrollTo client method). If another JavaScript relies on this type of listening, either StaticScrollBackPosition control will not work or the other JavaScript block(s) will not work correctly – so be warned that this will be the only known bug.

However, I did try to soften the blow and told it to attach to the window's load event and not the document's load event. Therefore, if you have some HTML, as shown below, this short-fall (bug) will not effect you at all:

<body onLoad="...">
   <!-- some code -->
</body>

View Entire Article

User Comments

Title: test   
Name: test
Date: 2011-01-18 4:26:27 PM
Comment:
Title: Not working in IE
Name: Ginu Mathai
Date: 3/5/2010 12:24:02 AM
Comment:
its not working in IE. So I made a small modification.

private const string ScriptGetPositionLine = ScriptHiddenField +
" = (navigator.appName == 'Netscape') ? window.page{1}Offset : ((document.body.parentElement) ? document.body.parentElement.scroll{2} :document.body.scroll{2});";
Title: With Update Panel   
Name: Mr .Shah
Date: 2010-07-28 8:38:29 AM
Comment:
Is this work where update panel is used ?????
Title: JSP / JAVA   
Name: peeter
Date: 2010-04-07 4:32:35 PM
Comment:
What are the changes I need to make for making it work in JSP.
Title: Not working in IE   
Name: Ginu Mathai
Date: 2010-03-05 12:24:02 AM
Comment:
its not working in IE. So I made a small modification.

private const string ScriptGetPositionLine = ScriptHiddenField +
" = (navigator.appName == 'Netscape') ? window.page{1}Offset : ((document.body.parentElement) ? document.body.parentElement.scroll{2} :document.body.scroll{2});";
Title: It works!   
Name: ganck
Date: 2009-11-24 12:15:36 AM
Comment:
I'm using Visual Studio 2003 and it works for me.
Thank you so much. [24-11-2009]
Title: Software Dev   
Name: Kevin Smith
Date: 2009-08-25 2:08:30 PM
Comment:
Sweet, finally, just what i was looking for, MS smartnavigation and maintainpositiononpostback were giving me endless javascript issues, you're works perfectly, thankyou!
Title: Didn't work for me   
Name: Chip J
Date: 2009-01-28 9:52:41 AM
Comment:
Not sure why this control didn't work for me, but MaintainScrollPositionOnPostBack = True did. Thanks for the effort.
Title: Awsome!   
Name: Steve R
Date: 2008-11-06 3:55:38 PM
Comment:
This is great, I've added it to my arsenal of weapons.
Title: nice job   
Name: nice job
Date: 2008-10-21 8:50:47 AM
Comment:
simple is the key, nice tool. lol to those saying it doesnt work and pitty would have been nice, you's may need to start w/ an asp primer before implementing custom controls to get the feel for proper implementation
Title: thank   
Name: danai
Date: 2008-10-17 1:03:39 PM
Comment:
thanks a lot...
Title: quick loans   
Name: quick loans
Date: 2008-10-08 11:03:22 AM
Comment:
can't get it to work on postback. works fine if i just set the scroll value myself.
Title: nice article   
Name: nn
Date: 2008-06-27 12:46:36 AM
Comment:
well done and very useful code...
thanks a lot...
Title: great yar , great   
Name: rajiv
Date: 2008-05-08 6:42:01 AM
Comment:
keep it up
Title: great!   
Name: uj
Date: 2008-04-29 6:02:10 PM
Comment:
thanks a lot! usage is simple and it works great!!
Title: Doesn't Work   
Name: Sean
Date: 2007-10-29 1:32:42 PM
Comment:
It's unfortunate, this doesn't work at all. Just does nothing. Would have been nice.
Title: Requirements   
Name: Patrice
Date: 2007-09-02 2:48:49 PM
Comment:
Can anyone tell me, please, if this requires sharepoint services? I'm getting a "resource cannot be found" error.

Thank you!
Title: Wow!   
Name: Chris
Date: 2007-08-29 12:39:48 AM
Comment:
I used this control on my personal website. It works great. Not to mention it was easy to setup. It takes a true programmer to come up with such a tool. I hope I can learn how to do that someday.
Title: You are the man   
Name: Manoochehr
Date: 2007-08-08 4:48:42 AM
Comment:
Hey thanks . I was mixed up with this issue but you solved it easily . you are the man . I like you
Title: MaintainScrollPositionOnPostBack   
Name: GD
Date: 2007-07-26 8:33:10 AM
Comment:
MaintainScrollPositionOnPostBack = True

does everythign the convoluted javascript alternatives do!
Title: Mr.   
Name: Faraz
Date: 2007-05-24 8:29:33 AM
Comment:
It's not working if the button is inside usercontrol(ascx) neither does MaintainScrollPositionOnPostback. any idea?
Title: Works like a charm   
Name: Kirit Raja
Date: 2007-05-22 10:33:02 AM
Comment:
It works like a charm. It resolved my long standing issue. Thanks a lot.
Title: Thanks   
Name: Juan Francisco (juan.espin@yahoo.com)
Date: 2007-03-30 5:10:55 PM
Comment:
Tahnks a lot for your code.

If I can help you in anything, please contact me

Best Regards
Title: thanks   
Name: sam
Date: 2007-03-29 2:14:04 AM
Comment:
i like this artical
Title: PHP apache   
Name: Nico van de Kamp
Date: 2007-02-02 5:37:26 AM
Comment:
I don't understand it completely but I need de server control's binary? But I saw there are DLL's in it. So is this solution only available for IIServer?

By the way I have some input fields on the document and then a long record list set, positioned with a div. Somebody can choose a record by double clicking on it. After double clicking on a record the document is submitted to the server.

Can someone help me?

Thanks in advance?
Title: SmartNavigation without your Control !!!!!!   
Name: Abdulla Hussein
Date: 2007-01-29 3:30:30 AM
Comment:
Hi , There is a line code that can do the smartNavigation without using your serverControl
just write the following code in the page_Load

Me.MaintainScrollPositionOnPostBack = True

Please if you see this reply tell me if my code does not work in some diffrent browsers :-)
Title: This is the Greatest!!!!   
Name: Tuong Do
Date: 2006-12-27 11:55:47 AM
Comment:
This is a great control that works perfectly!!! I spent hours looking something that would work!!
Title: Worthless   
Name: Josh
Date: 2006-12-22 12:26:16 PM
Comment:
This doesnt work. Do not waste your time, becuase this guy has a function called on the Onload of the window that sets scroll to 0,0 every time. This is worthless!
Title: Thanks   
Name: Ananya
Date: 2006-12-14 3:55:36 AM
Comment:
Thanks a ton for providing solution.
Title: is it coz i m using asp 2..0   
Name: aman
Date: 2006-11-10 8:22:04 AM
Comment:
referring to the above comment is it coz I am doing that in asp 2.0

is there a simpler way to do it in asp .net 2.0
Title: does not work in IE   
Name: aman
Date: 2006-11-10 8:15:19 AM
Comment:
I got the code working

I have put it in the master page of my project

I copied the dll from therelease folder

problem is

it works with firefox
but doesn't work with IE

can you please tell me the solution
Title: Thanks a lot !   
Name: Cyrille
Date: 2006-10-30 7:45:49 AM
Comment:
It's simple and efficient... I needed to make editable a huge table and it work perfectly...

Brilliant!
Title: Keeping Scroll Position over post Backs   
Name: Ted Green
Date: 2006-10-17 11:39:42 AM
Comment:
It Works! simple and sweet! Thanks very much.
Title: Awesome   
Name: Chad
Date: 2006-09-25 5:08:11 PM
Comment:
Thanks a million. I was pulling my hair out trying to fix the postback issue. This fixed it.
Title: Re: Problems with master pages in ASP.NET 2.0   
Name: Tomasz Saluszewski
Date: 2006-09-11 10:23:51 AM
Comment:
I've slightly modified the control described in http://aspnet.4guysfromrolla.com/articles/111704-1.aspx and it worked (both IE and Safari)!
The only thing I had to do to overcome 'master pages' problem was to chamge the way aspnet form is located in javascript. Here is the code:
var aspForm = document.forms['aspnetForm'];
if (!aspForm) {
aspForm = document.aspnetForm;
}
Title: Problems with master pages in ASP.NET 2.0   
Name: Tomasz Saluszewski
Date: 2006-09-01 3:42:34 AM
Comment:
I am having a problem using Your control in my ASP.NET 2.0 web pages. I suspect it's due I am using master pages. I've tried placing the control in both master and content page, but neither worked. Any ideas?

p.s.
I cannot use ASP.NET 2.0 MaintainScrollPosition page attribute as it doesn't work in Safari, which I need to support.
Title: Great Stuff   
Name: David Ross
Date: 2006-08-31 7:25:28 AM
Comment:
Absolutely Superb. Well done

It worked like a dream and only two lines of code for me!
Title: Thank you very much for your help   
Name: Fedor
Date: 2006-08-22 7:22:49 AM
Comment:
Thank you for solving this annoying problem of losing scroll position at postback. This gives me a lot more freedom of choosing a long data entry form instead of having to cut it up, divide it over several webforms, or hide portions of it...

Thanks again!
Title: Thanks   
Name: Amit
Date: 2006-08-14 8:05:02 AM
Comment:
Thanks...My problem has been solved.
May you live long.
Title: Developer community inc   
Name: Kumar
Date: 2006-08-04 7:24:49 AM
Comment:
Ya it is working fine we sorted out problem with scrolling is fixed after postback.thanks
Title: .Net 2.0   
Name: Giovanni
Date: 2006-08-02 3:33:03 PM
Comment:
Does your control work in asp.net with 2.0?

ggomez@alum.syracuse.edu
Title: Please Interpret   
Name: John Cahill
Date: 2006-08-01 10:30:59 PM
Comment:
Hi, Justin,

The thing you built sounds just what I need but I don't know a lot about this, so, if you wouldn't mind:

What, exactly, does this mean, "Drop the compiled assembly into your bin folder and you are set to go." What is the "compiled assembly"? Is it a file? I could guess it is the 'StaticPostBackPosition.dll' file but ... that would be a guess. I don't know what a compiled assembly is so please explain? "Bin" folder? Firstly, what machine ... the web server? "Bin" folder ... I have searched my computer and there are 19 Bin folders. Which one should I put the "compiled assembly" in?

Thanks, in anticipation, for your clarification.

John
Title: Good Job   
Name: Dan
Date: 2006-07-24 5:29:51 PM
Comment:
Works great! Thanks!
Title: Tweak   
Name: Adam
Date: 2006-07-12 3:46:32 PM
Comment:
To get this to work in IE 6, I had to change document.body to document.documentElement
Title: Javascript error   
Name: Bala
Date: 2006-07-11 9:11:17 PM
Comment:
It works fine...
But..
When I use javascript calendar control, after postback i get javascript error and calendar control is not getting loaded
Title: Thanks   
Name: Manny
Date: 2006-07-11 1:11:52 PM
Comment:
Thanks so much! Its working great.
Any suggestions for retaining the scroll position in a div tag.

Manny
Title: great   
Name: adam
Date: 2006-07-06 5:57:04 AM
Comment:
worked first time, job well done
Title: Thanks   
Name: Gary
Date: 2006-06-30 2:37:42 PM
Comment:
Justin,

THANKS! This made my job so easy.
Title: astonishingly simple   
Name: Arun N Mahendrakar
Date: 2006-06-29 12:30:09 PM
Comment:
dudeee.. this was too easy dudeee

Thanks dudeee
Title: Sytem Analysist   
Name: Fed Derring
Date: 2006-06-27 10:40:26 AM
Comment:
Hi
I too am getting the errror

"document.forms.0.StaticPostBackScrollVerticalPosition is null or not an object" even though i have it in a server form.
I tried this(as suggested by Tim Mackey

document.serverForm and made sure that all my server forms had ID=serverForm.
It still fails. Is there any other hints you can provide to solve this?
Thanks - fed email:frank.deering@qwest.com
Title: adding this control   
Name: HELP
Date: 2006-06-16 12:31:25 AM
Comment:
Can you please clarify exactly how to add this control to my project?
Title: Thanks..You are Genius   
Name: Mithilesh Deshpande
Date: 2006-06-15 5:59:53 PM
Comment:
Hi Justin,

Thanks a lot...your code is Just-In..as your name.

This really helped in our project, we use a Calendar control, which uses IFRAME and with SmartNavigation, it was not getting rendered on Postback.

Bye bye to SmartNavigation and Welcome to StaticPostBackPosition

:)

Mithilesh
Title: Scroll position   
Name: Debojyoti Bose
Date: 2006-05-24 1:28:25 AM
Comment:
Good article.We faced the problem of scroll positioning in JSP.We added the code snippet and that works.
Title: Muy Bueno   
Name: Val
Date: 2006-05-14 7:38:19 PM
Comment:
Este pequeño .dll es fantástico, es lo que andaba buscando, graciass.
Title: Scrolls Works with Div and page scroll   
Name: xtremexploit@hotmail.com
Date: 2006-04-06 10:23:44 AM
Comment:
I have a control like this, BUT my control works with Div and preserve the page scroll...

send me a email xtremexploit@hotmail.com and i will send my controls for free.. (VB.NET)
Title: I have a control   
Name: I have a control
Date: 2006-03-11 12:27:06 PM
Comment:
I have a control like this, buy my controls works with Div and preserve the page scroll...

send me a email xtremexploit@hotmail.com
Title: Thanks   
Name: Chris
Date: 2006-03-09 2:13:13 AM
Comment:
It works. Great!
Title: This could save the world   
Name: Osama
Date: 2006-03-08 8:06:53 PM
Comment:
This is great. I ported it over to VB and I was in business. Very simple and works well.
Title: Works PERFECTLY!   
Name: Jeremy Reid
Date: 2006-03-06 3:42:22 PM
Comment:
Thanks so much man, it works perfectly. This was exactly what I was looking for. You just saved me so much time!

Thaks again.
Title: Thanx a lot   
Name: Ravi Khatri
Date: 2006-02-22 12:47:51 AM
Comment:
Thanx a lot JUSTIN. Simply great job
Title: What about Div element (or panel for that matter)   
Name: Felipe B.
Date: 2006-02-16 6:53:41 AM
Comment:
Is It possible to do the same with Div elements or Panels?
I usually use Div with autoscroll and inside it some datagrid with a select button, so when It's clicked It does a PostBack loosing the original position in the Div or panel.
Thanks
Title: You are the Man!   
Name: Lee
Date: 2006-02-08 5:55:05 PM
Comment:
Your control is bad to the bone. Just what I've been trying to accomplish. It works so well I honestly didn't think the page was even posting back. Thanks for your time and effort and making this great control available to the development community.
Title: I'm Impressed   
Name: Pablo Ganga
Date: 2006-02-07 7:33:15 AM
Comment:
I'm impressed this control is awesome
Title: Wow   
Name: Joel
Date: 2006-01-26 9:11:16 PM
Comment:
That is amazing. Installing it was way easier than I tried to make it. a person just needs to literally drop the dll file into the bin directory and then add the control to the page. WOW!!!!!
Title: Machi Super Machi - Thanks Machi.   
Name: Govind
Date: 2006-01-06 8:00:07 AM
Comment:
Its really wonderful, Now you have made an improvement over smartnavigation that having some flaw like CSS has been disappeared. now this looks simple and GREAT!!
Title: Thanks from Justin to Justin   
Name: Justin
Date: 2005-11-28 6:19:17 PM
Comment:
Thanks a lot for your control,

Its very easy to use.

Justin
Title: Thank!   
Name: bull_evil
Date: 2005-11-10 11:54:48 AM
Comment:
excelent in all the web said use the dam smart...Navi..shit..really thank a lot work very fine.
All you have to do it download the source.zip inside you will find StaticPostBackPosition.dll extract to somewhere then in vb.net...in the tool box panel...secundary mouse click then add..remove items then you have to search the somewhere path (extract path or look for dll) accept...you will see a new tool icon "StaticPostBackPosition", thats it you only have to drag and drop the new tool..vb.net do the work.
Title: Thanks!   
Name: Marc
Date: 2005-11-02 7:32:01 AM
Comment:
My javascript menu's would not work on postback with smartnavigation.

This totally solved the problem for me - Thanks!
Title: MaintainScrollPositionOnPostback   
Name: SC
Date: 2005-10-26 4:17:22 PM
Comment:
ASP.NET 2.0 has a property called MaintainScrollPositionOnPostBack. Works nice.
Title: available for jsp?   
Name: smurfy
Date: 2005-10-18 3:50:17 AM
Comment:
does anyone know if this cool thing is also available for jsp?
Title: DBA/Developer   
Name: Yen Yeoh
Date: 2005-10-16 9:11:18 PM
Comment:
Many Thanks Justin. It's working well!
Yen.
Title: Thanks   
Name: IndianaJonas
Date: 2005-10-14 1:52:07 AM
Comment:
Thanks Thanks Thanks
Title: Is It Suppose To Work Like This ?   
Name: Raf
Date: 2005-09-30 3:14:10 PM
Comment:
hey, the thing is awesom, really saves trouble, but when i used it in my asp pages, on eveypostback it jerks to the top and then comes to the scroll position. Is it suppose to be like that or is it because of any other reason?
Title: Thanks a Lot   
Name: Bhargav Joshi
Date: 2005-09-29 12:26:36 PM
Comment:
Thank you solved an irritating problem for me!
Title: Very nice   
Name: Reynold Tucan
Date: 2005-09-22 6:38:10 PM
Comment:
Very nice and easy to use solution. Solved the problem that SmartNavigation caused (disappearing javascript menu on postback). Awesome and thanks.
Title: Brill, neat and simple   
Name: Zoli
Date: 2005-08-07 10:10:10 AM
Comment:
Thanks Justin, I've had so many problems with that dreadful SmartNavigation and now thanks to you, there is no need to use it anymore.
Your solution works like dream.
Thanks again.
Title: Keeping Scroll Position over post Backs   
Name: xyv
Date: 2005-08-04 2:33:17 AM
Comment:
The Control is not working with Mozilla.
Title: smart navigation   
Name: pips
Date: 2005-07-27 7:28:17 AM
Comment:
Thank you so much. Smart nav worked on our dev machine but caused all sorts of technical problems when deploying to live! I needed a quick fix and you saved me having to write the control myself! You're a star and very generous sharing your work!!

Thanks!!
Title: not working in firefox   
Name: santhosh thomas
Date: 2005-07-25 11:12:53 AM
Comment:
hi, thanks for the code, its working in IE. But its failing in firefox (1.0.4)
Title: Greate Control   
Name: GWH
Date: 2005-07-20 5:15:32 PM
Comment:
Great control Jorge Arturo Aviles Nuñez; It works great.
Thanks
Title: GREAT   
Name: Eric Kwerreveld
Date: 2005-07-01 10:03:09 AM
Comment:
Great control!!! Thanks a lot, just what i needed.
Title: Brilliant   
Name: Graeme
Date: 2005-06-21 5:23:14 PM
Comment:
That is the quickest easiest thing I have ever had to do. It works a treat and I have placed it into all my applications.

Thanks you for the control!!! You are brilliant!!!
Title: Thanks!   
Name: Abdulla
Date: 2005-06-04 1:52:54 PM
Comment:
Thank you a lot for your control....
Title: You are fantatic   
Name: Kent
Date: 2005-04-22 12:29:16 AM
Comment:
The control is great... Thank to post this control
Title: Awesome!   
Name: Awesome!
Date: 2005-04-06 10:09:13 AM
Comment:
Awesome!
Title: Thanks   
Name: D
Date: 2005-03-16 6:29:50 PM
Comment:
Thanks a lot, it save me headache and time. Also a great sample for a newbe.
Title: Good one   
Name: Rajesh
Date: 2005-03-05 6:40:20 AM
Comment:
This is a good control and very easy to install. Thank you very much
Title: Please Help!!!   
Name: Victoria
Date: 2005-03-03 3:31:49 PM
Comment:
I'm getting the following error:

"JIT Debugging component registration is incorrect."

Do you think you can help???
Title: Getting that is null or not an object error   
Name: ewd
Date: 2005-03-01 3:05:36 PM
Comment:
Hi,

I'm getting this error when the project is copied to the test server:
"document.forms.0.StaticPostBackScrollVerticalPosition is null or not an object"

On my laptop is works as advertised. However in Visual Studio I get an error in the Design portion of the IDE for the form. In the upper left part of the screen it says "Error Creating Control - Staticpostbackposition1" and the info button says "Parse error: Unknown server tag jlc:Staticpostbackposition" I think it's having problems with the <@ Register... however I copied exactly what's on the page here. Anyone else seen this and no what bone head manuever I'm performing to get this? Other than that this is a great replacement for SmartNavigation!

Thanx,

Eric
Title: Oux   
Name: Smbie
Date: 2005-02-17 9:08:43 PM
Comment:
Stream, the control works great!

Thanks!!
Title: what about IE?   
Name: David Lee
Date: 2005-02-16 7:14:46 PM
Comment:
did i miss something? or.. does this assume SmartNav is still on for IE?

I have a server form, tag is inside form.. and it doesn't work in IE. (haven't tried FireFox yet)
Title: Stream   
Name: Jorge Arturo Aviles Nuñez
Date: 2005-02-16 3:47:50 AM
Comment:
Example of my Control:
Protected WithEvents CtrlPreserveScrolls1 As CtrlPreserveScrolls


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
CtrlPreserveScrolls1.Add( CtrlPreserveScrolls.TypeControl.DIV, "DivUsuarios")
CtrlPreserveScrolls1.Add( CtrlPreserveScrolls.TypeControl.DIV, "DivMaestros")
CtrlPreserveScrolls1.Add( CtrlPreserveScrolls.TypeControl.DIV, "DivAgentes")
CtrlPreserveScrolls1.Add( CtrlPreserveScrolls.TypeControl.THEWINDOW)
End If
End Sub
Title: Stream   
Name: Jorge Arturo Aviles Nuñez
Date: 2005-02-16 3:33:09 AM
Comment:
Hello, I have modified the code source, and I have created "webControl" able to keep the position from any DIV and scroll of the page.

Hola, he modificado el codigo fuente, Y he creado un "webControl" capaz de guardar la posicion de cualquier DIV y el scroll de la pagina.

You can see it from here:
http://www.clikear.com/portalweb/Grids.aspx

And can be downloaded here:
http://www.clikear.com/portalweb/ScrollForDivs_AND_ThePage.zip

Thanks rookK by the link, gracias viejo :D

Saludos
Title: So close...   
Name: Kevin
Date: 2005-02-11 9:57:40 AM
Comment:
This is exactly what I have been searching for. I'd be thrilled if I could just get it to work.

Any idea why this would work in mozila but not IE? IE isn't throwing an error but it's not working either.
Title: Why scrolls always jumps to 400?   
Name: Uros
Date: 2005-02-07 8:36:02 AM
Comment:
Hy!

I have the same questions like Terry... I copy/pasted the code to the page, but now scrolls always jumps to 400, so I don't get this function:

function RestoreScrollPosition()
{
scrollTo(0, 400);
}

It should jump to previous state (before postback)?
Title: Thanks   
Name: L.D.
Date: 2005-01-11 2:39:25 PM
Comment:
Wonderful! All formatting and scroll positions are preserved (they were was lost with SmartNavigation). Thanks a lot!
Title: asp.NET developper (MCAD)   
Name: Simon Jarry
Date: 2004-12-23 12:30:12 AM
Comment:
Thanks a lot ! I really appreciate this control I have been installing on every of my projects now ! this is the final solution.. forget SmartNavigation !!!
Title: tip for null error   
Name: Tim Mackey
Date: 2004-11-23 6:02:24 AM
Comment:
hi,
i also got the error:
"document.forms.0.StaticPostBackScrollVerticalPosition is null or not an object" even though i had it in a server form. the problem was that i had some html forms before the server form, and obviously then the hard coded document.forms[0] was referring to the wrong one. i changed this code reference to: document.serverForm and made sure that all my server forms had ID=serverForm.
this is a great control. thanks for making it freely available.
Title: Sapient Corporation   
Name: Jassi
Date: 2004-11-22 12:39:04 PM
Comment:
Thanks.... this is a real cool stuff...
Title: Fantastico   
Name: Gift
Date: 2004-11-02 5:35:25 AM
Comment:
Thatz gr8, thankx a lot
Title: Developer   
Name: Moojjoo
Date: 2004-10-27 2:55:22 PM
Comment:
How do I get this control to show up in my toolbox?
Title: Happy Bunny   
Name: Norry Passway
Date: 2004-10-27 6:20:02 AM
Comment:
Great! Amazing to think that it wasn't a feature of ASP.NET. Works a treat and I am a happy bunny. Thanks for posting this solution.
Title: Finally, a scroll-position script that works!   
Name: Todd Taylor
Date: 2004-10-26 2:11:39 PM
Comment:
Thanks for posting this solution, Justin. I tried multiple other solutions to the scroll-position problem, but all the other solutions seemed to either create new problems or they just didn't work with my web pages dynamic panels. You solution seems to work perfectly :)
Title: Cool Control   
Name: Saharul Nizam Saaidi
Date: 2004-10-20 9:01:00 PM
Comment:
I would like to thank you for creating this control. I think it is a cool control. It is simple control, but to me it is very useful.

Thanks a lot.
Title: Damn good   
Name: chaminda jayakody
Date: 2004-10-13 2:26:49 PM
Comment:
i love u man,
Title: Mr   
Name: Doug Stowell
Date: 2004-10-05 9:34:21 AM
Comment:
Really helpful - got me out of a potential showstopper!!! Thanks.
Title: thanks a lot   
Name: Frances
Date: 2004-09-30 6:57:33 AM
Comment:
You made me a very happy person!
Title: Thanks!!   
Name: Yeiouaryii
Date: 2004-09-29 3:36:32 AM
Comment:
Perfect!
Thank you very much.
Title: RestoreScrollPosition?????   
Name: Terri
Date: 2004-09-23 8:27:05 PM
Comment:
Maybe I'm missing something but when I put this in my code it always scrolls to 400 (or whatever the last number is). I see the comment says determined during runtime but don't see how since the numbers are hard coded.

function RestoreScrollPosition() { scrollTo(0, 400); // determined during run-time}
Title: Re: Client Script Errors   
Name: Justin Lovell
Date: 2004-09-22 1:06:26 PM
Comment:
Hi guys,

I bet you that most of the problems is caused under the following scenerios:

* You don't have a server-side form.
* The control was not dropped in a server side form.

To resolve the problem, do the converse (opposite) of the things that you are doing wrong where it applies.

Cheers,
Justin
Title: StaticPostBackScrollVerticalPosition   
Name: Stuart
Date: 2004-09-22 12:23:17 PM
Comment:
Justin,

I am also getting a client side script error with the message that "document.forms.0.StaticPostBackScro
llVerticalPosition is null or not an object"

Regards,
Stuart
Title: "RE:Looks like Stanley Glass's code?" and "RE: Works like a charm for me so far"   
Name: Justin Lovell
Date: 2004-09-19 3:40:08 AM
Comment:
Luu and Stan,

I have blogged a response to both of your comments over here: http://blogs.aspadvice.com/jlovell/archive/2004/09/18/1683.aspx
Title: Works like a charm for me so far   
Name: Luu
Date: 2004-09-17 8:18:36 PM
Comment:
This will save a lot of people frustration using smart navigation. This is what you would expect from the development community and shows we are all out to solve the same problems. I hope Microsoft solves this problem with ASP.NET 2.0?

Thanks, Justin
Title: Thanks   
Name: Joe
Date: 2004-09-14 6:35:09 PM
Comment:
Thank you very much for this control, there's only one bug when I use a DataGrid + nested ASP Repeater, the problem is because I use a CheckBox to display the Nested ASP Repeater so with your control it doesn't scrolls down well because it only counts the pixels (rows) the first time the page is loaded so when it is refreshed it doesn't returns to your exact position.
Title: StaticPostBackScrollVerticalPosition   
Name: Rahul
Date: 2004-09-14 3:33:49 AM
Comment:
hey Justin,

we are getting a client side script error with the message that "document.forms.0.StaticPostBackScrollVerticalPosition is null or not an object"

Any help would be much appreciated.

Regards,
Rahul
Title: Re: Only works on refresh not postback   
Name: Justin Lovell
Date: 2004-09-11 1:10:18 PM
Comment:
Don,

You are required to have a server side form for the JavaScripts to register. Please check this.

Thanks,
Justin
Title: Only works on refresh not postback   
Name: Don
Date: 2004-09-11 8:27:35 AM
Comment:
After being frustrated with SmartNavigation I tried this control and found that it only works on a forced refresh not on a postback. This is similar yet a different condition than Lou posted. Is there any code I need to write in the Page_Load?
Title: Woo Hoo   
Name: Ahmed
Date: 2004-09-06 4:59:42 AM
Comment:
Justin Lovell is the coolest guy ever. I appreciate you sharing the knowledge. Take it easy...
Title: Many Thanks   
Name: Bill Potter
Date: 2004-09-01 8:49:18 AM
Comment:
Many thanks this was exactly what I was looking for.
It has solved various problems I have had with various sites
Bill
Title: Excellent solution   
Name: DanielG
Date: 2004-08-23 6:44:58 PM
Comment:
This is just wath I need. Works great!!!
Title: Work great with my templated site   
Name: Scott
Date: 2004-08-20 7:25:36 PM
Comment:
Could you add IE to the script? or is it just best to use smartnavigation?

Cheers, saved me a huge headache. :-)
Title: Groooooovy!   
Name: Tammy
Date: 2004-08-19 10:30:14 AM
Comment:
A perfect solution! It rocks! No more smartnavigation!
Title: Thanks   
Name: Eric
Date: 2004-08-03 12:46:09 AM
Comment:
Thanks...it works great...beside improve the CSS problem, it also allow the ASP.NET popup a new child window with focus..
Title: Works great -but   
Name: Lou
Date: 2004-07-26 11:22:10 PM
Comment:
This does a great job of maintaining scroll position during postbacks but it causes my javascript menu bar to disappear from the screen until I do a clean reload of the page. Therefore I sadly cannot use it in my application. Anyone know a possible workaround?

Lou
Title: ??!!   
Name: Elaine
Date: 2004-07-13 11:50:37 AM
Comment:
I am getting the following error when I try to use this control:

"document.forms.0.StaticPostBackScrollVerticalPosition is null or not an object"

Any help would be much appreciated.

Elaine
Title: Very Good.   
Name: Gopi
Date: 2004-07-05 7:22:52 AM
Comment:
Thanks!!. The Controls works fine. It is appeciated if the control also get the focus() of the last postbacked control.
Title: President Hallandales Inc.   
Name: Gary Eisert
Date: 2004-07-01 6:05:57 PM
Comment:
Thanks a million for your time and the expense of putting these solutions on the Internet for developers to solve these kinds of problems.

Works just fine!! 86 SmartNavigation....
Title: Thanks!   
Name: Christy
Date: 2004-06-26 1:42:40 PM
Comment:
Thanks so much! I was having a problem with the SmartNavigation in that I had a Calendar control that is called from a pulldown menu. The SmartNavigation always gave the main page the focus, which would hide the calendar page. Your application solved this - thanks!

Christy

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-18 1:38:19 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search