Whats the best way to close an open window

6 posts, 0 answers
  1. Kevin
    Kevin avatar
    58 posts
    Member since:
    May 2009

    Posted 30 Jun 2009 Link to this post

    Hi
    im using the radwindows manager to create new windows for different senarios but i would like to know what is the best way to close these windows programmatically

    Many thanks in advance
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Jun 2009 Link to this post

    Hello Kevin,

    Try the following code snippet in order to close the RadWindow from code behind of dialog page.

    CS:
     
    protected void Button1_Click(object sender, EventArgs e)    
         string script = "<script language='javascript'type='text/javascript'>Sys.Application.add_load(CloseWindow);</script>";   
         ClientScript.RegisterStartupScript(this.GetType(), "Close", script);    

    JavaScript:
     
    <script type="text/javascript">        
    function CloseWindow(sender, args)        
    {            
        GetRadWindow().close();       //closes the window        
    }        
    function GetRadWindow()   //Get reference to window     
    {        
        var oWindow = null;        
        if (window.radWindow)        
             oWindow = window.radWindow;        
        else if (window.frameElement.radWindow)        
             oWindow = window.frameElement.radWindow;        
        return oWindow;        
    }        
    </script>     

    Thanks,
    Shinu
  3. Kevin
    Kevin avatar
    58 posts
    Member since:
    May 2009

    Posted 30 Jun 2009 Link to this post

    Hi Shinu
    i have put that into my code but im now getting an object not defined error when i try to run it
    thanks
    Kevin
  4. Phil
    Phil avatar
    273 posts
    Member since:
    Jul 2008

    Posted 30 Jun 2009 Link to this post

    Hi:
    The above is placed in the windowed form.  Not the parent.  I use a variant of the above, using ScriptManager instead of ClientScript ... thusly, I do not need the <script> tags:
    Protected Sub CloseForm() 
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Close", "GetRadWindow().Close();", True) 
    End Sub 
     

  5. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 02 Jul 2009 Link to this post

    Hi Kevin,

    I believe that the following links will be of help as well:

    Greetings,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Martin
    Admin
    Martin avatar
    585 posts

    Posted 02 Jul 2009 Link to this post

    Hi Kevin,

    I believe that the following links will be of help:


    Greetings,
    Martin Ivanov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top