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

Show RadWindow on Page_Load

2 Answers 230 Views
Window
This is a migrated thread and some comments may be shown as answers.
urbanBaldGuy
Top achievements
Rank 1
urbanBaldGuy asked on 27 Aug 2008, 09:33 PM
I have a RadWindow that I am launching, I want to show a second RadWindow automatically if the user has opted to use my wizard.

If I use a button to launch the second window it works fine, if I try to do it automatically on Page_Load I get the error 'undefined is null or not an object'.

Here is the code behind:
if (!IsPostBack && Profile.UseOrderWizard)  
        {  
            ClientScript.RegisterStartupScript(this.GetType(), "NewOrderWizard", "<script type='text/javascript'>ShowOrderWizard();</script>");    
        } 

Here is the javascript:
<script type="text/javascript">  
        function ShowOrderWizard() {  
            window.radopen("NewOrderWizard.aspx", "NewOrderWizard");  
            return false;  
        }  
    </script> 

Here is the RadWindow Object:

<telerik:RadWindowManager ID="rwmNewOrder" runat="server" Behaviors="Reload,Close" Skin="Vista" Modal="true"   
    VisibleStatusbar="false" ReloadOnShow="true" ShowContentDuringLoad="false">  
        <Windows>      
            <telerik:RadWindow ID="NewOrderWizard" runat="server" Width="700" Height="460" /> 
        </Windows> 
    </telerik:RadWindowManager>    

2 Answers, 1 is accepted

Sort by
0
Sophy
Telerik team
answered on 28 Aug 2008, 11:24 AM
Hi Rob,

The error you receive when try to open a second window on Page_Load is most probably due to the RadWindow still has not been created. The order in which the client events are fired in the page life cycle is 
window.onload -> Sys.Application.init -> Sys.Application.load
The client object representation of the MS AJAX controls are created in the Sys.Application.init event, which is raised after the window.onload event. For that reason you can get a reference to the RadWindow no earlier that in the Sys.Application.load event, which is raised after all scripts have been loaded and the objects in the application have been created and initialized.
In your case you will need to replace 
<script type='text/javascript'>ShowOrderWizard();</script>
with
<script type='text/javascript'>Sys.Application.add_load(ShowOrderWizard);</script>
and the error should not appear.
If you need further assistance, do contact us again.

Best wishes,
Sophy
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
urbanBaldGuy
Top achievements
Rank 1
answered on 28 Aug 2008, 03:22 PM
Thanks, that worked great!
Tags
Window
Asked by
urbanBaldGuy
Top achievements
Rank 1
Answers by
Sophy
Telerik team
urbanBaldGuy
Top achievements
Rank 1
Share this question
or