This is a migrated thread and some comments may be shown as answers.

Maintain the scroll position on page reload

6 Answers 668 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Manisha
Top achievements
Rank 1
Manisha asked on 03 May 2013, 06:28 AM
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

6 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 06 May 2013, 01:42 PM
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.
0
Manisha
Top achievements
Rank 1
answered on 07 May 2013, 01:10 PM
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
0
Rumen
Telerik team
answered on 08 May 2013, 07:58 AM
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.
0
Manisha
Top achievements
Rank 1
answered on 10 May 2013, 09:36 AM
Hi Rumen,

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

Thanks,

Manisha
0
Rumen
Telerik team
answered on 10 May 2013, 01:12 PM
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.
0
Manisha
Top achievements
Rank 1
answered on 13 May 2013, 05:46 AM
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
Tags
Editor
Asked by
Manisha
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Manisha
Top achievements
Rank 1
Share this question
or