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

Opening RadWindow from code behind

2 Answers 338 Views
Window
This is a migrated thread and some comments may be shown as answers.
Hunter
Top achievements
Rank 1
Hunter asked on 18 Feb 2013, 08:53 PM
I've tried doing this many different ways with no success.

I just want to open a RadWindow from code behind (the initiating action is from a RadDock command).

Here is the aspx:
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"  >
    <AjaxSettings >
        <telerik:AjaxSetting AjaxControlID="RadDockLayout1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadDockZone1" LoadingPanelID="RadDRadAjaxLoadingPanel1ockZone1" />
                <telerik:AjaxUpdatedControl ControlID="rwinProperties" LoadingPanelID="RadDRadAjaxLoadingPanel1ockZone1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="rwinProperties">
            <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone1" LoadingPanelID="RadDRadAjaxLoadingPanel1ockZone1" />           
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>
<telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" Skin="Black" />
 
    <telerik:RadDockLayout ID="RadDockLayout1" runat="server" Skin="Default" OnSaveDockLayout="RadDockLayout1_SaveDockLayout"
        OnLoadDockLayout="RadDockLayout1_LoadDockLayout" StoreLayoutInViewState="True">
        <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="1400px" Width="1100px" Skin="Black" Orientation="Horizontal">
 
        </telerik:RadDockZone>
    </telerik:RadDockLayout>
 
    <asp:Label id="lbCurrentProperty" runat="server" visible="false" />
 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <Windows>
            <telerik:RadWindow ID="rwinProperties" runat="server" Title="Select Properties" Height="550px"
                Width="450px" Left="150px" ReloadOnShow="false" VisibleOnPageLoad="false" ShowContentDuringLoad="false" CssClass="RadWindow"
                Modal="true">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

In the RadWindow I want to display a web page (SelectProperties.aspx) which as three parameters in the query string.

Here's one attempt:
Dim URL As String = "SelectProperties.aspx?SectionID=" + SectionID + "&SectionCount=" + SectionCount + "&SectionName=" + SectionName
Dim script As String = "function f(){radopen(""" + URL + """,""rwinProperties"").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
 
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", Script, True)

When I use this approach I get the following error: Microsoft JScript runtime error: Unable to get value of the property 'parentNode': object is null or undefined.  In researching this error I got now help in trying to figure out why I got this error.  So I tried another approach and got the same error:

Sub DisplayProperties(ByVal SectionID As String, SectionCount As String, ByVal SectionName As String)
        Dim script As String = "Sys.Application.add_load(ShowSelectProperties(""" & SectionID & """,""" & SectionCount & """,""" & SectionName & """));"
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", Script, True)
End Sub

function ShowSelectProperties(SectionID, SectionCount, SectionName)
{
    radopen("SelectProperties.aspx?SectionID=" + SectionID + "&SectionCount=" + SectionCount + "&SectionName=" + SectionName, "rwinProperties");
 
}


Any help is greatly appreciated. 


2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 19 Feb 2013, 12:16 PM
Hi Hunter,

Here are the issues I can find with these snippets:

1) the initiator of the request would be the dock whose command is clicked, not the zone
2) the RadWindow does not need to be updated in order for the script registration to work, nor can it be an initiator of an AJAX request
3) radopen() alone is enough to show the popup

So, here is how the AJAX settings look like:
<telerik:AjaxSetting AjaxControlID="RadDock1">
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="RadDockZone1" LoadingPanelID="RadDRadAjaxLoadingPanel1ockZone1" />
    </UpdatedControls>
</telerik:AjaxSetting>

with a simple dock
<telerik:RadDockZone ID="RadDockZone1" runat="server" Height="1400px" Width="1100px"
    Skin="Black" Orientation="Horizontal">
    <telerik:RadDock runat="server" ID="RadDock1">
        <Commands>
            <telerik:DockCommand AutoPostBack="true" Name="OpenRW" Text="Open RadWindow" />
        </Commands>
    </telerik:RadDock>
</telerik:RadDockZone>

and the code-behind (I only made your variables strings to avoid compilation errors on my end)
Dim URL As String = "SelectProperties.aspx?SectionID=" + "SectionID" + "&SectionCount=" + "SectionCount" + "&SectionName=" + "SectionName"
Dim script As String = "function f(){radopen(""" + URL + """,""rwinProperties""); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
 
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)


Since you may have more than one dock that will do this you may consider programmatic creation of these AJAX settings or using a regular ASP UpdatePanel, use its Triggers collection to populate with each dock and set the ChildrenAsTriggers property to false.

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
Hunter
Top achievements
Rank 1
answered on 19 Feb 2013, 09:10 PM
Marin,

Thanks for the quick response.  Your solution to launch the window works perfectly.  (Though I thought I tried a variation of this without success.)

And yes, I am creating the RadDocks dynamically so I will have to add these as Ajax Settings dynamically too.  I've tried this without success so far, but I will open a different thread for this and close this thread.
Tags
Window
Asked by
Hunter
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Hunter
Top achievements
Rank 1
Share this question
or