[CLOSED] Problem closing parent window

  1. #1

    [CLOSED] Problem closing parent window

    Hi i'm trying to close the parent window of a page that is called inside a window in a iframe.

    I looked inside the forum and couldn't find the answer.

    I try to close the actual window using the Ext.WindowMgr.getActive().close().

    I don't know why, but the Ext.WindowMgr.getActive() returns null

    The error says:Error:
    Ext.WindowMgr.getActive() is null
    Archivo Fuente: http://localhost:4519/extjs/ext-all-js/ext.axd?v=21945
    Línea: 9

    Any help or idea?



    Heres is my code to reproduce the problem:


    TestMain.aspx:
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Init(object sender, EventArgs e)
        {
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            PanelCenter.LoadContent(new LoadConfig("TestParent.aspx", LoadMode.IFrame));
        }
    </script>
    
    <!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 runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" Theme="Gray" runat="server" DebugConsole="Ext" />
         <ext:Viewport ID="Viewport1" runat="server" Layout="border">
            <Items>
                <ext:Panel ID="PanelWest" runat="server" Title="Módulos " Region="West" Frame="true" Width="210" Floating="true" Collapsible="true">
                       <Content>
                        </Content>
                </ext:Panel>
                <ext:Panel ID="PanelCenter" runat="server" Region="Center" Border="true" Padding="5">
                </ext:Panel>
            </Items>
        </ext:Viewport>
        <div>
        
        </div>
        </form>
    </body>
    </html>
    Test_Parent.aspx:
    <%@ Page Language="C#" %>
    
    <script runat="server">
    
        class SomeClass
        {
            public string ID { get; set; }
            public string Test { get; set; }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            Store store = this.GridPanel1.GetStore();
            JsonReader reader = new JsonReader();
            reader.IDProperty = "ID";
            reader.Fields.Add(new RecordField("id") { Mapping = "ID" });
            reader.Fields.Add(new RecordField("test") { Mapping = "Test" });
            store.Reader.Add(reader);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.HyperLink1.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click_Event);
            LoadData();
        }
        protected void LoadData()
        {
            Store store = this.GridPanel1.GetStore();
            store.DataSource = new object[]
                {
                    new SomeClass()
                    {
                        ID = "id1",
                        Test = "test1"
                    },
                    new SomeClass()
                    {
                        ID = "id2",
                        Test = "test2"
                    },
                    new SomeClass()
                    {
                        ID = "id3",
                        Test = "test3"
                    }
                };
            store.DataBind();
        }
    
        void Click_Event(object sender, DirectEventArgs e)
        {
            HyperLink1.Enabled = false; // se oculta cuando esta deshabilitado
            
            var win = new Window
            {
                ID = "Window1",
                Title = Title,
                Width = Unit.Pixel(800),
                Height = Unit.Pixel(600),
                Modal = true,
                Closable = false,
                Collapsible = false,
                Maximizable = false,
                Maximized = true,
                Hidden = false,
                AutoScroll = true
            };
            win.AutoLoad.Url = "Test_ABM.aspx";
            win.AutoLoad.Mode = LoadMode.IFrame;
            win.ShowModal();
            win.Render();
            this.Controls.Add(win);
    
            HyperLink1.OnClientClick = "#{Window1}.show();return false;";
        }
        
    </script>
    
    <!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 runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" Theme="Gray" runat="server" DebugConsole="Ext" />
        <div>
            <ext:LinkButton ID="HyperLink1" Text="Open" runat="server"/>
        
            <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Reader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column Header="ID" DataIndex="id" />
                        <ext:Column Header="Test" DataIndex="test" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                </SelectionModel>
            </ext:GridPanel>
        </div>
        </form>
    </body>
    </html>
    Test_ABM:
    <%@ Page Language="C#"  %>
    <script runat="server">
        protected void Page_Init(object sender, EventArgs e)
        {
            ButtonClose.Listeners.Click.Handler = "Ext.WindowMgr.getActive().close()";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    </script>
    <!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">
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" Theme="Gray" runat="server" DebugConsole="Ext" />
        <div>
    BOTONA
            <ext:Button ID="ButtonClose" runat="server" Text="Cancelar"></ext:Button>
    BOTONB
    </div>
        </form>
    </body>
    </html>
    Last edited by Daniil; Jan 24, 2012 at 7:33 AM. Reason: [CLOSED]
  2. #2
    Hi,

    As far as I can understand there is no window in the Test_ABM.aspx page, right?

    It's an iframe and, respectively, it has a own Ext.WindowMgr instance which knows nothing about parent page's Windows. Generally, an iframe has own Ext.NET/ExtJS scripts at all since it's considered a separated page.

    To access a parent page from its iframe, please use the iframe's "parent" property.

    Example
    parent.Ext.WindowMgr.getActive().close();
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    As far as I can understand there is no window in the Test_ABM.aspx page, right?

    It's an iframe and, respectively, it has a own Ext.WindowMgr instance which knows nothing about parent page's Windows. Generally, an iframe has own Ext.NET/ExtJS scripts at all since it's considered a separated page.

    To access a parent page from its iframe, please use the iframe's "parent" property.

    Example
    parent.Ext.WindowMgr.getActive().close();
    You'r right... i used to have parent. i don't know why i changed... i think that i should write another example, because this one worked but in my real life situation doesn't work.

    I have all extnet controls wrapped inside user controls. So i will have to format them to make them little and simple as possible.
  4. #4
    Ok, please feel free to update the thread with a sample to reproduce.

Similar Threads

  1. [CLOSED] Problem: Closing Maximized Window will loose parent window scrollbar
    By tlfdesarrollo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 19, 2012, 8:51 PM
  2. Replies: 7
    Last Post: Feb 09, 2012, 11:17 AM
  3. Problem closing a Window! :D
    By csn in forum 1.x Help
    Replies: 2
    Last Post: Jun 23, 2011, 4:09 AM
  4. Replies: 4
    Last Post: Nov 22, 2010, 10:25 AM
  5. Closing a parent window from code behind
    By Kamal in forum 1.x Help
    Replies: 2
    Last Post: Sep 29, 2009, 8:25 PM

Posting Permissions