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

OnFocus causing Parent to Scroll to Top

1 Answer 178 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 29 Jul 2013, 05:09 PM
We have several pages that are rendered in RadWindows from a Parent page.  To speed along keyboard driven entry, we were setting the focus to the first prompt in the RadWindow - but when we do this, it seems that the Parent Screen will always scroll to the top (which is not the behavior we want).  We have moved the focus code from code behind to javascript, but the problem persists.

Is there a recommended way to handle this?  For now we have removed the .focus() calls and the problem has gone away - but we would like to set the focus on load in the RadWindow while holding the scroll position on the parent page.

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 01 Aug 2013, 03:16 PM
Hello Dan,

The call to Focus() is a common reason for such behavior. RadWIndow renders with JavaScript as the first child of the <form> element, and then positions absolutely. The server-side Focus() method registers a script to execute and call the client-side focus() method of the designated control, yet this script runs too early and the browsers tend to miscalculate the actual position of the textbox and believe it is in the beginning of the form.

What should be done is to use the Sys.Application.Load event to add the focus and use a small timeout. An example of this can be seen in this forum post.

Regards,
Danail Vasilev
Telerik
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 the blog feed now.
Tags
Window
Asked by
Dan
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or