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

radwindow moves by itself after opening

7 Answers 258 Views
Window
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 21 Sep 2012, 12:42 PM
Hi..

This happens only in chrome.. the radwindow moves up after laoding.. It is maximized onload by javascript..

works fine in mozilla / IE ..issue is in chrome only...

please help..

7 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 25 Sep 2012, 10:09 AM
Hi Nick,

There are two cases when I have seen such behavior and they are both related to the way the browser works:

1) if you are opening the RadWindow onclick of an anchor and the anchor's href attribute is set to a sharp sign (#) the browser will scroll the target into view, which can cause this behavior. You need to change the href to javascript:void(0); This will also apply to ASP LinkButtons - OnClientClick and NavigateUrl are the properties that render as the onclick and href attributes

2) The page/content you have inside the RadWindow has default focus, especially set on the server (e.g. TextBox1.Focus() in the Page_Load handler). This also causes the browser to scroll to the focused element. The way to avoid it is to either remove the default focus, or to use JavaScript and a small timetout in the Sys.Application.Load event.


Regards,
Marin Bratanov
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
Nick
Top achievements
Rank 1
answered on 28 Sep 2012, 05:14 AM
Hi Marin!

The information provided by you is helpful..
Appreciate your response.
Thanks a lot..
0
Bob Areddy
Top achievements
Rank 1
answered on 18 Jan 2013, 04:38 PM
Marin, 

Can you give a sample of the code that would fix the 2nd scenario?  Thanks.
0
Marin Bratanov
Telerik team
answered on 22 Jan 2013, 10:56 AM
Hello Bob,

Here is a simple example:
//instead of
//TextBox1.Focus();
string script = "function f(){setTimeout(function(){$get('" + TextBox1.ClientID + "').focus();},0);Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "focusingKey", script, true);

You can, of course, declare the function in the page's markup, call it from the code behind and only pass the ClientID of the desired control as a parameter. This depends on your preferences.

Greetings,
Marin Bratanov
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
Randy
Top achievements
Rank 1
answered on 09 Aug 2013, 06:44 PM
I was sent here from another post but I cannot get the JavaScript to work correctly.

I changed it to call a function defined on the ASPX page with the setTimeout, but no matter what, the parent page scrolls to the top of the screen behind the radwindow.  It does return to where it should be when the window closes, but we really don't want the parent screen to scroll in the first place.

function setFocusName()
{
    setTimeout($get('tFirstName').focus(), 0);
}

Dim script As New StringBuilder
script.Append("function f()")
script.Append("{")
script.Append("   setFocusName();")
script.Append("   Sys.Application.remove_load(f);")
script.Append("}")
script.Append("Sys.Application.add_load(f);")
 
ScriptManager.RegisterStartupScript(Page, Page.GetType, "focusingKey", script.ToString(), True)

Thanks,

Randy
0
Marin Bratanov
Telerik team
answered on 13 Aug 2013, 09:06 AM
Hi Randy,

There may be other reasons for this behavior like an anchor with href="#" or a postback.
Solution for the former is using href="javascript:void(0);" and using partial postbacks for the latter, as they do not usually affect the page scrolling.

If neither helps I would suggest that you post here the code that leads to the problem in its minimal version (i.e. the way you open the RadWindow and the simplest content page that shows the problem). Only once we can examine the problem we may be able to help.


Regards,
Marin Bratanov
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.
0
Jonathan
Top achievements
Rank 1
answered on 21 May 2015, 03:34 AM

Using  a jquery timeout seems to work after setting the ClientIDMode to static on the control to which you wish to set focus: 

$(document).ready(function () {
                setTimeout(function () { $('#txtComment').focus(); }, 100);
            });

Tags
Window
Asked by
Nick
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Nick
Top achievements
Rank 1
Bob Areddy
Top achievements
Rank 1
Randy
Top achievements
Rank 1
Jonathan
Top achievements
Rank 1
Share this question
or