[CLOSED] Passing value from Popup window to Parent window is throwing error

  1. #1

    [CLOSED] Passing value from Popup window to Parent window is throwing error

    Hi,

    I would like to know how to pass some information from popup window to parent window. I would like to activate one button event in parent form, from popup window. I have given popup window ID in main page and trying to hide popup window using that window ID, but it is throwing error.

    Main Page Code

    
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">     
        protected void Page_Load(object sender, EventArgs e) {
            if (!X.IsAjaxRequest) { 
                CreateTestButtonsAndTextFields(); 
            } 
        }
    
        public void CreateTestButtonsAndTextFields()
        { 
            Ext.Net.Button btnTest;
            Ext.Net.TextField txtFld;
            for (int i = 0; i < 3; i++) { 
                btnTest = new Ext.Net.Button(); 
                btnTest.Text = "Button " + i.ToString(); 
                btnTest.ID = "btn" + i.ToString();
                btnTest.Flex = 1;
                btnTest.Listeners.Click.Handler = "Ext.net.DirectMethods.LoadWindow(this.id);";
                txtFld = new Ext.Net.TextField();
                txtFld.ID = "txtfld" + i.ToString();
                
                FieldSet1.Items.Add(btnTest); 
                FieldSet1.Items.Add(txtFld);
            } 
        }
    
        public void ReloadSpecificInfo(object sender, DirectEventArgs e)
        {
            //code to refresh
        }
                                
        [DirectMethod]
                                
        public void LoadWindow(string id) { 
            MyWindow w = new MyWindow() { 
                ID = "Window1", 
                Title = "Title " + id 
            }; 
            w.AutoLoad.Params[0].Value = id;
            w.Modal = true;
            w.Render(); 
        }
                                
        class MyWindow : Window { 
            private Unit width = new Unit(400); 
            
            public override Unit Width { 
                get { 
                    return this.width; 
                } 
            } 
            
            private Unit height = new Unit(400); 
            
            public override Unit Height { 
                get { 
                    return this.height; 
                } 
            } 
            
            private LoadConfig loadConfig; 
            
            public override LoadConfig AutoLoad { 
                get { 
                    if (loadConfig != null) { 
                        return loadConfig; 
                    } 
                    loadConfig = base.AutoLoad; 
                    loadConfig.Url = "TestWindow.aspx"; 
                    loadConfig.Params.Add(new Ext.Net.Parameter() { 
                        Name = "id", 
                        Mode = ParameterMode.Value 
                    }); 
                    loadConfig.Mode = LoadMode.IFrame; 
                    return loadConfig; 
                } 
            } 
        } 
        </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">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:FormPanel ID="FormPanel1" runat="server">
            <Items>
                <ext:FieldSet ID="FieldSet1" runat="server" />
                <ext:Button ID="btnRefresh" runat="server" Text="Refresh">
                <DirectEvents>
                <Click OnEvent ="ReloadSpecificInfo"></Click>
                </DirectEvents>
                </ext:Button>
            </Items>
        </ext:FormPanel>
        </form>
    </body>
    </html>
    Child Form Code
    
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">     
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Label1.Text = this.Request["id"];
        } 
    </script>
    <script type="text/javascript">
        
    </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">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Label ID="Label1" runat="server" />
        <ext:Button ID="Save" runat="server" Text="Save" Icon="Disk" Width="120">
            <Listeners>
                <Click Handler="parent.txtfld1.SetValue(Label1.GetValue())" />
            </Listeners>
        </ext:Button>
        <ext:Button ID="btnCancel" runat="server" Text="Cancel" Icon="Cancel" Width="120">
            <Listeners>
                <Click Handler="#{Window1}.hide()" />
            </Listeners>
        </ext:Button>
        </form>
    </body>
    </html>
    Last edited by Daniil; Mar 15, 2011 at 7:50 AM. Reason: [CLOSED]
  2. #2
    Hi,

    #{Window1} doesn't make sense because Window1 is presented in another page. #{} has access to the controls of that page where #{} is used.

    Please use
    parent.Window1.hide()
    or
    parent.Ext.getCmp(Label1.getText()).hide()
    Another issue in your samples is :
    <Click Handler="parent.txtfld1.SetValue(Label1.GetValue())" />
    Must be .setValue() and .getText().

Similar Threads

  1. Replies: 1
    Last Post: Jun 18, 2012, 3:41 PM
  2. How to passing value from Window to Parent?
    By titasix in forum 1.x Help
    Replies: 3
    Last Post: Mar 12, 2012, 3:46 AM
  3. [CLOSED] Button event is not firing in parent window from popup window
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 14, 2011, 7:35 PM
  4. Replies: 1
    Last Post: Mar 14, 2011, 4:20 PM
  5. [CLOSED] Loading UserControl window from Parent Form throwing error
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 10, 2011, 3:43 PM

Tags for this Thread

Posting Permissions