|
-
Sep 10th, 2010, 09:42 AM
#1
Thread Starter
New Member
scrollToTop and AJAX
Hi all - I'm attempting to have my page automatically scroll to the top when there is an error message to present to the user. Following a tip I found searching, I've enclosed the Javascript scrollTo function in a setTimeout function to avoid a conflict with AJAX remembering the scroll position. Here is the relevant code:
Code:
Private Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete
If CType(msgNewInvoice.FindControl("litMessage"), Literal).Text <> "" Then
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "GoToTop", "setTimeout(""window.scrollTo(0, 0)"", 0);", True)
' setTimeout is necessary here because without it AJAX takes priority and will maintain scroll position.
End If
End Sub
This is working fine for me locally, but when I move the code up to our test server, it does not seem to take effect. I have tried increasing the length of the timeout, but no dice. Any ideas on what might different in the test server environment? Thanks for any insight.
-
Sep 10th, 2010, 11:19 AM
#2
Re: scrollToTop and AJAX
Is this an ASP.NET question?
-
Sep 10th, 2010, 11:31 AM
#3
Thread Starter
New Member
Re: scrollToTop and AJAX
My mistake. Sorry. 
Can this thread be moved?
Last edited by Straadin; Sep 10th, 2010 at 11:43 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|