[CLOSED] Executing actions on closing dinamically created windows

  1. #1

    [CLOSED] Executing actions on closing dinamically created windows

    Hello,

    I have make a simple example illustrating what I want to do. (and I am not able to find how to do it)

    1- I have a main page which contains a panel which shows an specific url
    2- I open a dinamically created window which contains another page
    3- from inside the page of the dinamically created window, I want to refresh/change the url of the panel in the main window (i.e. combined with the closing of the window, the actions done in the closed window alters the information, so the frame in the main window should be refreshed)


    What I do not know how to do is how to refresh /change the url of the panel in the main page wron the page in the window.
    The idea is that the "Close window" button also reload/change the url of the "myWebPanel" panel in the main page.

    Any ideas about how to do that?

    Thank you.

    Here is the code
    Main.aspx
    <%@ Page    Language           = "C#"%>    
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {            
                Coolite.Ext.Web.Button btncreate=new Coolite.Ext.Web.Button();
                btncreate.Text="Create Window";
                btncreate.StyleSpec="margin: 2px;";
                btncreate.MinWidth=100;
                string script="newWindow('window.aspx', {id: 'LKF_00000FGT',title: 'Test window', height: 200, width: 300, modal:true});";           
                btncreate.OnClientClick=script;
                Form.Controls.Add(btncreate);
                //panel with an url
                Coolite.Ext.Web.Panel webpanel=new Coolite.Ext.Web.Panel();
                webpanel.ID="myWebPanel";
                webpanel.Height=300;
                webpanel.Width=600;
                webpanel.AutoLoad.Url="http://www.ext.net";
                webpanel.AutoLoad.Mode= LoadMode.IFrame;
                webpanel.AutoLoad.MaskMsg="Loading...";
                webpanel.AutoLoad.ShowMask=true;
                Form.Controls.Add(webpanel);
                //this is the action that I want to be performed from the opened window
                Coolite.Ext.Web.Button btnchangeURL=new Coolite.Ext.Web.Button();
                btnchangeURL.Text="Change URL and reload";
                btnchangeURL.StyleSpec="margin: 2px;";
                btnchangeURL.MinWidth=100;
                script="#{myWebPanel}.load({url:\"http://www.google.com\"});";               
                btnchangeURL.OnClientClick=script;
                Form.Controls.Add(btnchangeURL);
            }
        </script>
        
        <script type="text/javascript">
            var newWindow = function (url, config) {
                new Ext.Window(Ext.apply({
                    renderTo: Ext.getBody(),
                    resizable: false,
                    title: "Test",
                    height: 500,
                    width: 500,
                    frame: true,
                    autoLoad: {
                        maskMsg: "Loading...",
                        showMask: true,
                        mode: "iframe",
                        url: url
                    }
                }, config)).show();
            }
        </script>
        
        
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="scriptManager" runat="server"/>        
            
        </form>
    </body>
    </html>
    window.aspx
    <%@ Page    Language           = "C#"%>    
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {            
                Coolite.Ext.Web.Button btnclose=new Coolite.Ext.Web.Button();
                btnclose.Text="Close Window";
                btnclose.StyleSpec="margin: 2px;";
                btnclose.MinWidth=100;
                string script="parent.window.LKF_00000FGT.close();";   
                //the following  line does not work :(
                script+="parent.window.#{myWebPanel}.load({url:\"http://www.google.com\"});";
                btnclose.OnClientClick=script;
                Form.Controls.Add(btnclose);
            }
        </script>
        
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="scriptManager" runat="server"/>        
            
        </form>
    </body>
    </html>

  2. #2

    RE: [CLOSED] Executing actions on closing dinamically created windows

    Hi,

    There are two incorrect thing in your code:


    1. You can't reference with #{} syntax on controls from another pages because current page doesn't know about controls from another page. Therefore using #{myWebPanel} is incorrect in window.aspx. Change it to the myWebPanel (or correct ClientID)


    2. First you need first call 'load' for parent panel and only after that you can close the window otherwise 'close' method will destroy iframe and you can't reference on parent page
    string script = "parent.window.myWebPanel.load({url:\"http://www.google.com\"});";
    script += "parent.window.LKF_00000FGT.close();";
  3. #3

    RE: [CLOSED] Executing actions on closing dinamically created windows

    Thank you,

    Now it works.

    Please, mark thread as closed.

Similar Threads

  1. [CLOSED] Add button to dinamically created window toolbar
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Oct 13, 2011, 4:07 PM
  2. Replies: 6
    Last Post: Nov 02, 2010, 3:25 PM
  3. [CLOSED] [1.0] Closing windows?
    By edigital in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 05, 2010, 3:28 PM
  4. [CLOSED] [1.0] get value of dinamically created control
    By miguelon in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 27, 2010, 4:01 PM
  5. [CLOSED] Closing dinamically created windows
    By jcanton in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 23, 2009, 9:24 AM

Posting Permissions