Window returns null until page finishes loading?

2 posts, 0 answers
  1. Dan
    Dan avatar
    13 posts
    Member since:
    Nov 2009

    Posted 27 Sep 2011 Link to this post

    Hi,

    I have the following javascript method to create a RadWindow.

    function ShowModalWindow(cLinkName, args, width, height) 
    {
        var oWnd = radopen(cLinkName, "ModalDialog");
          
        if(oWnd != null)
        {
            if (width != null)
                oWnd.SetSize(width, height);
      
            oWnd.Center();
      
            var arg = new Object();                    
            //Using an Object as a argument is convenient as it allows setting many properties.   
            arg.descriptionValue = args;
              
            oWnd.Argument = arg;
        }
        radWindow = oWnd;
    }

    The problem is that I have a page with a lot of graphs. If the button that calls the above javascript is clicked before the page is done loading then oWnd is null and the size does not get set. The window still opens correctly but the size is something like 50x50 instead of 800x600.

    Is there a simple or preferred way to handle this?
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4609 posts

    Posted 29 Sep 2011 Link to this post

    Hello Dan,

    This is the expected behavior when the page is not fully loaded. Any AJAX-enabled controls are created after the window.onload event and are available at earliest in the Sys.Application.Load event (a shortcut to that is the pageLoad() function). What you can do is raise a flag in this function that the page is ready and check for this flag in your function. If the page is not yet ready - do not attempt to access the RadControls and perhaps alert the user that he/she needs to wait for the page to load.


    Best wishes,
    Marin
    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
Back to Top