[CLOSED] How to create tab control from direct event

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] How to create tab control from direct event

    Dear supporter,

    I created a tabpanel with an user control from button in TapPanel.aspx by direct event, but other direct event from user control ElementChooser.ascx is not worked (if tab panel added from page_load is ok)
    Here my sample, please help me to fix
    1. TabPanel.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TabPanel.aspx.cs" Inherits="WebApplication1.TabPanel" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <%@ Register Src="~/ElementChooser.ascx" TagPrefix="uc" TagName="Chooser" %>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>Adding Tabs On The Fly - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                //Ext.Net.Panel panel = new Ext.Net.Panel
                //{
                //    Title = "New Tab",
                //    Closable = true,
                //    Items = { 
                //        new UserControlLoader{
                //            Path="ElementChooser.ascx",
                //            UserControlID="Chooser2",
                //        }
                //    }
                //};
    
                //TabPanel1.Add(panel);
            }
    
            protected void addTabDirect(object sender, Ext.Net.DirectEventArgs e) {
                Ext.Net.Panel panel = new Ext.Net.Panel
                {
                    Title = "New Tab",
                    Closable = true,
                    Items = { 
                        new UserControlLoader{
                            Path="ElementChooser.ascx",
                            UserControlID="Chooser2",
                        }
                    }
                };
    
                TabPanel1.Add(panel);
                panel.Render(true);
            }
    
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
            <ext:Button ID="button001" runat="server" Text="Add tab button">
                <DirectEvents>
                    <Click OnEvent="addTabDirect"></Click>
                </DirectEvents>
            </ext:Button>
            <ext:Window ID="Window1"
                runat="server"
                Title="Adding tab"
                Width="700"
                Height="500"
                Icon="Link"
                Layout="BorderLayout">
                <Items>
                    <ext:TabPanel ID="TabPanel1" runat="server" Region="Center" >
                       <%--<Items>
                            <ext:Panel ID="childPanel01" runat="server" Title="hello">
                                <Content>
                                        <uc:Chooser ID="Chooser2" runat="server" />
                                </Content>
                            </ext:Panel>
                        </Items>--%>
                    </ext:TabPanel>
                </Items>
            </ext:Window>
        </form>
    </body>
    </html>
    2. ElementChooser.ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ElementChooser.ascx.cs" Inherits="WebApplication1.ElementChooser" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public void showMessage1()
        {
            X.Msg.Alert("Message box", "Hello message 1").Show();
        }
    </script>
    
    <ext:Button ID="button01" runat="server" Text="my Button">
        <Listeners>
            <Click Handler ="ShowMessageTest();"></Click>
        </Listeners>
    </ext:Button>
    
    <ext:DataView ID="DataView1" runat="server" 
        TrackOver="true"
        ItemSelector=".x-newtab-item"
        OverItemCls="x-newtab-over-item">
        <Tpl>
            <Html>
                <tpl for=".">
                    <div class="x-newtab-item">
                        <h1>{name}</h1>
                    </div>
                </tpl>
            </Html>        
        </Tpl>
        <Store>
            <ext:Store ID="Store1" runat="server">
                <Model>
                    <ext:Model ID="Model1" runat="server">
                        <Fields>
                            <ext:ModelField Name="name" />
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>
        </Store>
    </ext:DataView>
    
    <script type="text/javascript" >
        function ShowMessageTest() {
            App.direct.Chooser2.showMessage1();
        }
    </script>
    Too many thanks !
    Last edited by Daniil; Jan 29, 2015 at 8:44 AM. Reason: [CLOSED]

Similar Threads

  1. create direct event in runtime to MenuItem
    By elbanna23 in forum 1.x Help
    Replies: 7
    Last Post: Jan 10, 2012, 1:12 PM
  2. Replies: 5
    Last Post: Sep 19, 2011, 8:20 PM
  3. Replies: 7
    Last Post: Jun 28, 2011, 11:13 AM
  4. Replies: 8
    Last Post: Jun 24, 2010, 9:39 PM
  5. Replies: 3
    Last Post: May 11, 2010, 10:36 AM

Posting Permissions