This is a migrated thread and some comments may be shown as answers.
How to Close RADWindow from Web Page specified as NavigateURL
4 Answers 139 Views
This is a migrated thread and some comments may be shown as answers.
Vikas
Top achievements
Rank 1
Vikas asked on 18 Aug 2011, 12:25 AM
HI,

I am using RADWindow on Master page, when user clicks any button I have a JavaScript that finds, sets the NavigateURl property of RADWindow control as follows:

<

script type="text/javascript">  

 

function OpenCreateVirtualFarmWindow(button, args) {  

var oManager = GetRadWindowManager();  

var oWnd = oManager.getWindowByName("CaasRADWindow");  

oWnd.SetSize(400, 400);

oWnd.SetUrl("/CaasCustomerPortal/CreateFarm.aspx");  

oWnd.Show(); 

return false;   

}

</

script


Step 2) Inside the CreateFarm.aspx we have  a "Create" and "Cancel" button, I want to close this RADWindow when the user hits Cancel button. How to achieve that in the CreateFarm.aspx.cs, I mean how do I get reference to instance of RADWindow and CLOSE it?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 18 Aug 2011, 07:32 AM
Hello Vikas,
Try the the follwing client side code in the CreateFarm page to close the window.
Javascript:
<script type="text/javascript">
function GetRadWindow()
    {
        var oWindow = null;
        if (window.radWindow) oWindow = window.radWindow;
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
        return oWindow;
    }
function closeWindow()
    {
        var oWnd = GetRadWindow();
        oWnd.close();
    }
</script>

Thanks,
Shinu.
0
jlj30
Top achievements
Rank 2
answered on 09 Mar 2012, 10:26 PM
Shinu,

Thanks for the code.
I too had a need for this and it worked like a charm.

Jim
0
DEBAL
Top achievements
Rank 1
answered on 23 Mar 2012, 03:18 PM
HI
Shinu I have used same code , but when asp.net runs on IE then it throws error on GetRadWindow() , But in firefox and Mozilla are  working  fine. I Have simple PopUp window where there is some information user will create and there is two button like Submit and Cancel .  If user submitt button click then those information will bind in suppose for simplicity TextBox and if user click on Cancel button then PopUp window should vanish/close.

How to do this using Telerik Rad Window . Here is below code in design page :

 <telerik:RadWindowManager runat="server" Modal="True" Windows="RadWindow1" ID="radmanager">
            <Windows>
                <telerik:RadWindow ID="RadWindow1" Animation="Fade" Behaviors="Close" VisibleStatusbar="False"
                    runat="server"  Height="240px" Width="198px">
                    <ContentTemplate>
                     ........... 
                                    <asp:Button ID="Button2" runat="server" Text="Ok" />
                                    <asp:Button ID="Button3" runat="server" Text="Cancel" OnClick="CloseWindow()"/>
                 
                    </ContentTemplate>
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>

But  CloseWindow() function not working. The Code is same as described by you.
Thanks ,
0
Marin Bratanov
Telerik team
answered on 23 Mar 2012, 04:48 PM
Hi,

The GetRadWindow() function is designed for the content page, not for the ContentTemplate. In this case you are still in the context of the main page and thus you need to get a reference to the RadWindow in the standard AJAX way - via $find(). This is shown in the following online demo: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx.


All the best,
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.
Asked by
Vikas
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
jlj30
Top achievements
Rank 2
DEBAL
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or