sakir
sakir

Reputation: 3502

Ext.net:PreviousPage.FindControl issue

I have main page something like this.

<ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Gray" />
    <form id="form2" runat="server">
    <ext:Panel runat="server" ID="anaPanel" Title="OSO" Icon="Car">
        <TopBar>
            <ext:Toolbar runat="server" Layout="FitLayout">
                <Items>
                    <ext:Menu ID="Menu1" runat="server" Floating="false" Layout="HBoxLayout" ShowSeparator="false"
                        AnimCollapse="true" Cls="horizontal-menu">
                        <Defaults>
                            <ext:Parameter Name="MenuAlign" Value="tl-bl?" Mode="Value" />
                        </Defaults>
                        <Items>
                            <ext:MenuItem ID="MenuItem1" runat="server" Text="" Icon="Group">
                                <Menu>
                                    <ext:Menu ID="Menu2" runat="server">
                                        <Items>
                                            <ext:MenuItem Text="new card" Icon="GroupAdd">
                                           <DirectEvents>
                                           <Click OnEvent="AddNewCart_Click"></Click>
                                           </DirectEvents>

                                            </ext:MenuItem>
                                            ...............
                                            ...............
                                            </ext:Panel>
 <ext:Window runat="server" ID="MyWindow" Hidden="true"></ext:Window>
    </form>

My maninpage codebehind something like this.

 protected void AddNewCart_Click(object sender, DirectEventArgs e)
    {

        string path = "Pages/Kart.aspx";
        Window win = CreateWindows(MyWindow,Icon.Group,path,"new card", 420, 500);
        //private Window CreateWindows(Window Mywindow , Icon ic,string path,string Title, int Heigh, int With){......};
       //I get the MyWindow and pass some values and turn it back.
        win.Render(this.Form);
        win.Show();
    }

inside the Kart.aspx I have some buttons,my first question is ,how can I close this window .I put a button to close the this window(window which loaded Kart.aspx) ,here are the some way how I did.but none of them didnt work.

1-

 if (PreviousPage != null)//previouspage come as a null.
            {


                Window wnd = PreviousPage.FindControl("MyWindow") as Window;
                wnd.Close();
            } 

2-

 Window wnd =   Parent.Page.FindControl("MyWindow") as Window;
  wnd.Close();

3-I also tried to make MyWindow as public inside mainpage and try to reach it from Kart.aspx,but also didnt work my second question is ,how can I pass the parameters between the those pages.

Upvotes: 0

Views: 632

Answers (1)

Mahmoud Darwish
Mahmoud Darwish

Reputation: 1161

you can do it in the client side by calling

    window.parent.Ext.getCmp('MyWindow').close();

Edit

the closest to a code behind call is to use

    btnClose.AddScript("window.parent.Ext.getCmp('MyWindow').close();");

Edit 2

if you code is more complex like reloading a grid or modifying forms, you do the following:

Code-Behind

    X.Call("ReloadGrid");

JavaScript

    function ReloadGrid() {
                var grid = window.parent.Ext.getCmp('GridId');
                //grid reloading code
    }

Upvotes: 1

Related Questions