Maintain the scroll position on page reload

7 posts, 0 answers
  1. Manisha
    Manisha avatar
    14 posts
    Member since:
    Mar 2013

    Posted 03 May 2013 Link to this post

    Hi,

    I am working on an ASP.Net website which is using the latest Telerik version Q3 2012 for Rad Ajax Controls. There are certain pages in my website which consist of 10-12 Rad Editors (each consisting of individual edit,save and review buttons). The issue is that suppose, I scroll down to any of the below editors on the page and then try to edit or save or any other function, the page reloads and takes me back to the top of the page. It causes a lot of trouble to scroll down again as well as create confusions in editing and saving.

    The Rad Ajax Panel contains the Editor and each of the controls like edit,save, etc are on a user control common to all pages.

    I tried using MaintainScrollPositionOnPostBack = true on individual pages, web.config and code behind but nothing helps.

    Please suggest me some way to maintain the scroll position on the editor which is being modified or used.

    Thanks,

    Manisha

  2. Rumen
    Admin
    Rumen avatar
    13884 posts

    Posted 06 May 2013 Link to this post

    Hello,

    RadEditor does not respect the MaintainScrollPositionOnPostback property. What the editor actually do is similar to (but not exactly the same as) taking the focus. The editor just gets the page selection in order to properly attach its event handlers to its content area. For unknown reason (looks like an IE bug or shortfall of the implementation) keyboard handlers would not properly attach, and the editor uses additional code to get the selection.

    What you can do is store the scroll position when submitting the page and on pageLoad to restore the scroll position using the following JavaScript code:


    //KEEP POSITION
    var oBody = document.body;
    var oDoc = document.documentElement;
    var top = oBody.scrollTop > oDoc.scrollTop ? oBody.scrollTop : oDoc.scrollTop;
    var left = oBody.scrollLeft > oDoc.scrollLeft ? oBody.scrollTop : oDoc.scrollLeft;

    //RESTORE POSITION
    oBody.scrollTop = top;
    oBody.scrollLeft = left;
    oDoc.scrollTop = top;
    oDoc.scrollLeft = left;

    All the best,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Manisha
    Manisha avatar
    14 posts
    Member since:
    Mar 2013

    Posted 07 May 2013 Link to this post

    Hi,

    I tried storing and setting the scroll positions but it did not resolve the issue. As I mentioned, each of the Rad Editor on the page has a User Control which is common to all. I tried setting scroll positions on both the main page and the user control as the page goes there on submission but to no help. The scroll behaves the same and reaches to the top of the page on every reload/refresh.

    Please any other suggestions ??


    Thanks,

    Manisha
  4. Rumen
    Admin
    Rumen avatar
    13884 posts

    Posted 08 May 2013 Link to this post

    Hi Manisha,

    Can you please isolate the problem in a simple working project and send it for examination along with reproduction steps? You can use the support ticketing system to provide the project files.

    Thank you for your assistance in advance.

    Best regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Manisha
    Manisha avatar
    14 posts
    Member since:
    Mar 2013

    Posted 10 May 2013 Link to this post

    Hi Rumen,

    The issue is resolved by storing the scroll position in a hidden element and restoring on page load.

    Thanks,

    Manisha
  6. Rumen
    Admin
    Rumen avatar
    13884 posts

    Posted 10 May 2013 Link to this post

    Hi Manisha,

    I am glad that you have implemented the desired functionality.

    It would be perfect If you would like to share your code with the community here or in the code library section of RadEditor.

    Best regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Manisha
    Manisha avatar
    14 posts
    Member since:
    Mar 2013

    Posted 13 May 2013 Link to this post

    Hi Rumen,

    I got the resolution from one of the Telerik asp.net forums posts. The link to that post is : http://forums.asp.net/t/1359867.aspx . Hope that helps someone else too.

    Thanks & Regards,

    Manisha
Back to Top