[CLOSED] call parent js function from client window

  1. #1

    [CLOSED] call parent js function from client window

    hi,

    i have open a new child window with autoLoad url page from parent window.. i have one js function in parent window, how i can call this js function from child page js function...
    Last edited by Daniil; Sep 23, 2010 at 4:13 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please investigate this example.
    https://examples1.ext.net/#/Panel/Ba...Communication/
  3. #3

    dynamic panel

    hi,

    your above example panel1,panel2 is static controls.. i need above sample for dynamic panels, when we create panels dynamically , we dont the id, only run time will findout the id's... please provide like that above sample for dynamic panel control id's...
  4. #4
    Hi,

    You can get any component by ID using Ext.getCmp method
    Ext.getCmp(myDynamicControlID)
    if control inside another iframe
    parent.Ext.getCmp(myDynamicControlID)
    or
    Panel1.getBody().Ext.getCmp(myDynamicControlID)
  5. #5
    Hi,

    I would suggest you to explicitly set a dynamically created Panel's ID

    Example
    Ext.Net.Panel panel1 = new Ext.Net.Panel() { ID = "Panel1" };
    or
    Ext.Net.Panel panel2 = new Ext.Net.Panel();
    panel1.ID = "Panel2";
    NOTE:
    Seems I misunderstood you, majestic.
    Please follow the Vladimir's recommendation.
    Last edited by Daniil; Oct 26, 2010 at 2:48 PM. Reason: Added note
  6. #6

    sample code

    hi,

    i have attached sample code, i dont know how to pass values between the dynamic panels.. plz see my sample..
    Attached Files
    • File Type: zip A.zip (1.6 KB, 132 views)
  7. #7
    Hi majestic,

    I would suggest you to pass an id in query string using this code:
    pnl1.AutoLoad.Params.Add(new Coolite.Ext.Web.Parameter("parentPanelId", "Panel2"));
    Please see the following sample.

    Example Parent Page
    <%@ 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">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Coolite.Ext.Web.Panel pnl1 = new Coolite.Ext.Web.Panel() { ID = "Panel1" };
                pnl1.AutoLoad.Url = "A.aspx";
                pnl1.AutoLoad.Mode = LoadMode.IFrame;
                pnl1.AutoLoad.ShowMask = true;
                pnl1.AutoLoad.Params.Add(new Coolite.Ext.Web.Parameter("parentPanelId", "Panel2"));
                Coolite.Ext.Web.Panel pnl2 = new Coolite.Ext.Web.Panel() { ID = "Panel2" };
                pnl2.AutoLoad.Url = "B.aspx";
                pnl2.AutoLoad.Mode = LoadMode.IFrame;
                pnl2.AutoLoad.ShowMask = true;
                pnl2.AutoLoad.Params.Add(new Coolite.Ext.Web.Parameter("parentPanelId", "Panel1"));
    
                Coolite.Ext.Web.Panel pnl3 = new Coolite.Ext.Web.Panel() { ID = "Panel3" };
                pnl3.AutoLoad.Url = "A.aspx";
                pnl3.AutoLoad.Mode = LoadMode.IFrame;
                pnl3.AutoLoad.ShowMask = true;
                pnl3.AutoLoad.Params.Add(new Coolite.Ext.Web.Parameter("parentPanelId", "Panel4"));
                Coolite.Ext.Web.Panel pnl4 = new Coolite.Ext.Web.Panel() { ID = "Panel4" };
                pnl4.AutoLoad.Url = "B.aspx";
                pnl4.AutoLoad.Mode = LoadMode.IFrame;
                pnl4.AutoLoad.ShowMask = true;
                pnl4.AutoLoad.Params.Add(new Coolite.Ext.Web.Parameter("parentPanelId", "Panel3"));
    
                Page.Controls.Add(pnl1);
                Page.Controls.Add(pnl2);
                Page.Controls.Add(pnl3);
                Page.Controls.Add(pnl4);
            }
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>IFrame Communication - Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ScriptManager runat="server" />
        <h1>
            IFrame Communication</h1>
        </form>
    </body>
    </html>
    A.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Hidden1.Value = this.Request["parentPanelId"];
        }
    </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>A.aspx</title>
    </head>
    <body>
        <form runat="server">
        <ext:ScriptManager runat="server" />
        <ext:Hidden ID="Hidden1" runat="server" />
        <ext:TextField ID="TextField1" runat="server" />
        <ext:Button runat="server" Text="To the B" Icon="ArrowRight">
            <Listeners>
                <Click Handler="parent.Ext.getCmp(Hidden1.value).getBody().TextField1.setValue(TextField1.getValue());" />
            </Listeners>
        </ext:Button>
        </form>
    </body>
    </html>
    B.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Hidden1.Value = this.Request["parentPanelId"];
        }
    </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>B.aspx</title>
    </head>
    <body>
        <form runat="server">
        <ext:ScriptManager runat="server" />
        <ext:Hidden ID="Hidden1" runat="server" />
        <ext:TextField ID="TextField1" runat="server" />
        <ext:Button runat="server" Text="To the A" Icon="ArrowLeft">
            <Listeners>
                <Click Handler="parent.Ext.getCmp(Hidden1.value).getBody().TextField1.setValue(TextField1.getValue());" />
            </Listeners>
        </ext:Button>
        </form>
    </body>
    </html>
  8. #8

    Clloite Method Access

    hi,
    how i can access Ajaxmethod from Default.aspx, which is there in the child Form A.aspx. i have tried
    parent.Ext.getCmp(Hidden1.value).getBody().Coolite.AjaxMethods.Rebind();
    but i got js error..


    Last edited by Daniil; Oct 29, 2010 at 10:19 AM. Reason: Please use [CODE] tags
  9. #9
    Hi,

    Please look at the example.

    A Button in Default.aspx
    <ext:Button runat="server" Text="A.aspx TestDirectMethod">
        <Listeners>
            <Click Handler="Panel1.getBody().Coolite.AjaxMethods.TestAjaxMethod();" />
        </Listeners>
    </ext:Button>


    AjaxMethod in A.aspx
    <script runat="server">
        [AjaxMethod]
        public void TestAjaxMethod()
        {
            Ext.Msg.Alert("A.aspx", "TestAjaxMethod").Show();
        }
    </script>

Similar Threads

  1. Replies: 6
    Last Post: Feb 15, 2012, 5:15 PM
  2. [CLOSED] Ext.Net.X.GetCmp - how to call in parent?
    By wagger in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 25, 2011, 5:55 AM
  3. [CLOSED] [1.0] Call to grid function from child window
    By edigital in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 16, 2010, 9:41 AM
  4. [CLOSED] Call client function on image button press
    By flormariafr in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 03, 2010, 9:34 AM
  5. [CLOSED] call function from child window
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Apr 29, 2009, 4:31 PM

Posting Permissions