Results 1 to 7 of 7

Thread: Reset scroll position of a page

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    90

    Reset scroll position of a page

    This must be an easy thing to do. In my app, I have a datagrid that I must scroll down the page to see. Then, when I click on an "exit" button with the following code behind

    Response.Redirect("ThisPage.aspx", True)

    The page is still scrolled down on "ThisPage.aspx".

    How do I reset the scroll position to the top on "ThisPage.aspx"?

    Thanks

  2. #2
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Hi, I don't know if this is the best way but you could always enter a HTML bookmark in the page..

    VB Code:
    1. <a name="TopOfPage">

    Then is your redirect statement

    VB Code:
    1. Response.Redirect("./MyRedirectedPage.aspx#TopOfPage")

    HTH
    MarkusJ

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    90
    If I am passing a parm is the syntax


    Response.Redirect("./MyRedirectedPage.aspx#TopOfPage?parm1=value")



    Thanks for all the help!!
    Last edited by jstansell; Feb 3rd, 2004 at 09:48 PM.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    90
    I tried this on a page that does not take a parm. It did not work. I think my problem is the fact that this page is actually inside an IFRAME. I need to scroll the parent form to top. Is there a way to access the parent form from a page that is inside an IFRAME?

  5. #5
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Hi, you will probably have to use javascript;

    something like

    VB Code:
    1. document.frames[0].location = 'http://www.mysite.com#TopOfPage'

    This will call the first frame in the document and set the location to the url you specified at the bookmark top of page.

    hth
    cheers
    MarkusJ

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    90
    Does this work with IFRAME's?

  7. #7
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Hi, should do as an Iframe is just another frame and should be part of the frames collection of the document.

    Basically, you just want to reload the page within the Iframe using Javascript (Check out Google for a page on how to do this).

    Once you have that sorted, you then want to place a bookmark in the page that will be contained within the Iframe near the top of the page.

    Once you have those two working combine the two

    VB Code:
    1. document.frames[0].location = 'http://www.mysite.com#TopOfPage'

    This should get you started
    Cheers
    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width