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

Window returns null until page finishes loading?

1 Answer 92 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 27 Sep 2011, 08:23 PM
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?

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 29 Sep 2011, 09:10 AM
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
Tags
Window
Asked by
Dan
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or