radwindow moves by itself after opening

8 posts, 0 answers
  1. Nick
    Nick avatar
    23 posts
    Member since:
    Jan 2012

    Posted 21 Sep 2012 Link to this post

    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..
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 25 Sep 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nick
    Nick avatar
    23 posts
    Member since:
    Jan 2012

    Posted 28 Sep 2012 Link to this post

    Hi Marin!

    The information provided by you is helpful..
    Appreciate your response.
    Thanks a lot..
  5. Bob Areddy
    Bob Areddy avatar
    9 posts
    Member since:
    Jul 2010

    Posted 18 Jan 2013 Link to this post

    Marin, 

    Can you give a sample of the code that would fix the 2nd scenario?  Thanks.
  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 22 Jan 2013 Link to this post

    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.
  7. Randy
    Randy avatar
    50 posts
    Member since:
    Aug 2010

    Posted 09 Aug 2013 Link to this post

    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
  8. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 13 Aug 2013 Link to this post

    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.
  9. Jonathan
    Jonathan avatar
    134 posts
    Member since:
    Sep 2007

    Posted 20 May 2015 Link to this post

    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);
                });

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017