How to Close RADWindow from Web Page specified as NavigateURL

5 posts, 0 answers
  1. Vikas
    Vikas avatar
    2 posts
    Member since:
    Aug 2011

    Posted 17 Aug 2011 Link to this post

    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?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Aug 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. jlj30
    jlj30 avatar
    101 posts
    Member since:
    Jan 2011

    Posted 09 Mar 2012 Link to this post

    Shinu,

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

    Jim
  5. DEBAL
    DEBAL avatar
    22 posts
    Member since:
    Oct 2012

    Posted 23 Mar 2012 Link to this post

    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 ,
  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 23 Mar 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017