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

How to close RadWindow from user control ?

1 Answer 204 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mateusz
Top achievements
Rank 1
Mateusz asked on 01 Aug 2011, 06:03 PM
Hi,
I have my RadWindow defined in one ascx file for example "controlParent". Content of this window is another ascx file for example "controlChild". How can I close my RadWindow by asp:button in control "controlChild" ?
My aspx file:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"/>
 <user:ContolParent runat="server" ID="cParent" />

ContorlParent.ascx:
<telerik:RadWindow ID="selectorPopupWindow" CssClass="rad_window" runat="server" Title="Galeria multimediów" Width="950" EnableEmbeddedSkins="false" Skin="MSIT_sitefinityLocal"
            Height="600" VisibleOnPageLoad="false" Behaviors="Minimize, Move, Maximize, Close"
            OffsetElementID="RadGrid1">
            <ContentTemplate>
                <user:ControlChild runat="server" ID = "cChild" />
            </ContentTemplate>
</telerik:RadWindow>


ContolChild.ascx:
Grids, TextBox etc.
<asp:Button runat="server" ID="btnCancel" Text="Cancel" />


I am thankful for any help,
Mateusz Wajcowicz

1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 03 Aug 2011, 01:13 PM
Hello Mateusz,

I think the simplest approach would be to add a property to your controlChild control, where you can pass a reference to a javascript function, which your Cancel button can call to close the RadWindow. So something like this:

ControlParent.ascx:
<telerik:RadWindow ID="selectorPopupWindow" CssClass="rad_window" runat="server" Title="Galeria multimediów" Width="950" EnableEmbeddedSkins="false" Skin="MSIT_sitefinityLocal"
            Height="600" VisibleOnPageLoad="false" Behaviors="Minimize, Move, Maximize, Close"
            OffsetElementID="RadGrid1">
            <ContentTemplate>
                <user:ControlChild runat="server" ID = "cChild" OnClientCancelButtonClicked="CloseRadWindow();return false;" /> 
            </ContentTemplate>
</telerik:RadWindow>
  
<script type="text/javascript">
    function CloseRadWindow(){
        $find("<%=selectorPopupWindow.ClientID%>").close();
    }
</script>

I added the Property OnClientCancelButtonClicked and passed in the reference to the javascript function that will close the RadWIndow. Below is the property definition for OnClientCancelButtonClicked.

ControlChild.ascx (Code-Behind) Property Definition:
public string OnClientCancelButtonClicked
{
    set
    {
        btnCancel.OnClientClick = value;
    }
}

I hope that helps.
Tags
Window
Asked by
Mateusz
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Share this question
or