How to close current tab(page)?

  1. #1

    How to close current tab(page)?

    Hi,

    I use tabs to manage a differente pages. But I'd like close the current tab when y click on a tab page button (using javascript o c# code). Is it possible? How can I do it?

    Thank you very much.
  2. #2
    Hi,

    You can use the following JavaScript from the Child Page.

    Example

    parent.Panel1.close();
    The "Panel1" is the Parent Panels .ClientID.

    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    The following example might help as well, see

    https://examples1.ext.net/#/Panel/Ba...Communication/
    Geoffrey McGill
    Founder
  4. #4
    Thanks, geoffrey.mcgill for your example

    I tried to do it:

    var closeTab = function (id) {
                var tab = PortalTabPanel.getItem(id)
                if (tab) {
                    tab.close();
                }
            }
    But tab.close() give me this error: the object does not accept this property or method.
    I also tried with hide method but doesn't work.

    What can be the mistake?

    Thank you a lot.
  5. #5
    Hi,

    Please look at the example.

    Parent Page
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" 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 runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:TabPanel ID="TabPanel1" runat="server">
            <Items>
                <ext:Panel ID="Panel1" runat="server" Title="Tab 1">
                    <AutoLoad Mode="IFrame" Url="TestIFrame.aspx">
                        <Params>
                            <ext:Parameter Name="containerID" Value="Panel1" />
                        </Params>
                    </AutoLoad>
                </ext:Panel>
                <ext:Panel ID="Panel2" runat="server" Title="Tab 2">
                    <AutoLoad Mode="IFrame" Url="TestIFrame.aspx">
                        <Params>
                            <ext:Parameter Name="containerID" Value="Panel2" />
                        </Params>
                    </AutoLoad>
                </ext:Panel>
            </Items>
        </ext:TabPanel>
        </form>
    </body>
    </html>
    Child Page
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Hidden1.Value = this.Request["containerID"];
        }
    </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>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Hidden ID="Hidden1" runat="server" />
        <ext:Button runat="server" Text="Close this tab">
            <Listeners>
                <Click Handler="parent.TabPanel1.closeTab(Hidden1.getValue());"/>
            </Listeners>
        </ext:Button>
        </form>
    </body>
    </html>
  6. #6
    This example is perfect.

    Thank you very much for your help :D:
  7. #7

    Worked for me

    Thank you Daniil, it worked for me (:
  8. #8
    Hi @stratek,

    Thank you for the feedback!

Similar Threads

  1. Close Curren Tab (from the Current Tab)
    By inaltec in forum 1.x Help
    Replies: 4
    Last Post: Nov 20, 2012, 3:05 PM
  2. Open form without leaving current page
    By Joffre Mota in forum 1.x Help
    Replies: 2
    Last Post: Jul 30, 2011, 8:38 PM
  3. Replies: 1
    Last Post: Nov 18, 2010, 5:21 AM
  4. Replies: 1
    Last Post: Nov 10, 2010, 8:47 PM
  5. Export only exporting what is in current page
    By rthiney in forum 1.x Help
    Replies: 1
    Last Post: Oct 13, 2009, 3:32 PM

Posting Permissions