[CLOSED] Using TabStrip, creating tab dynamically from codebehind, but NO LISTENERS on the 'TabStripItem'

  1. #1

    [CLOSED] Using TabStrip, creating tab dynamically from codebehind, but NO LISTENERS on the 'TabStripItem'

    Hi,
    When changing Tab the Notify Box is ALWAYS "Line 4"

    What result is needed:
    I need when I change the 'TabStripItem' the Notify Message should display each line as per their Tab.

    I notice there is NO LISTENERS on the 'TabStripItem'

    How would I get this result with TabStrip while creating it dynamically ??


    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Ext.Net" TagPrefix="ext" Namespace="Ext.Net" %>
    
    <script runat="server">         
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                var lines = new List<string>() { "Line 1", "Line 2", "Line 3", "Line 4" };
                for (int i = 1; i <= lines.Count; i += 1)
                {
                    //* NEW TabStripItem */                               
                    var tabStripItem = new TabStripItem
                                       {
                                           Title = lines[i - 1]
                                       };
    
                    TabStrip1.Listeners.TabChange.Handler = "Ext.net.DirectMethods.LoadActiveTab('" + lines[i - 1] + "');";
                    TabStrip1.Items.Add(tabStripItem);
                }
            }
        }
    
    
        [DirectMethod]
        public void LoadActiveTab(string tabName)
        {
            //X.Msg.Notify("The Server Time is: ", DateTime.Now.ToLongTimeString()).Show();
            X.Msg.Notify("Server Side, Tab clicked: ", tabName).Show();
        } 
        
    </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:TabStrip ID="TabStrip1" runat="server" />
        </form>
    </body>
    </html>
    Last edited by Daniil; May 30, 2012 at 8:57 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please replace
    TabStrip1.Listeners.TabChange.Handler = "Ext.net.DirectMethods.LoadActiveTab('" + lines[i - 1] + "');";
    with
    TabStrip1.Listeners.TabChange.Handler = "Ext.net.DirectMethods.LoadActiveTab(tab.title);";
  3. #3
    That works...

    Thank you very much...

    Quote Originally Posted by Daniil View Post
    Hi,

    Please replace
    TabStrip1.Listeners.TabChange.Handler = "Ext.net.DirectMethods.LoadActiveTab('" + lines[i - 1] + "');";
    with
    TabStrip1.Listeners.TabChange.Handler = "Ext.net.DirectMethods.LoadActiveTab(tab.title);";
  4. #4

    Update , this is what I actually wanted, maybe it can help others. (Shows the ID of the Active Tab when clicked)

    Once again thank you.

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Linq" %>
    <%@ Register Assembly="Ext.Net" TagPrefix="ext" Namespace="Ext.Net" %>
    
    <script runat="server">         
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                var lines = new[]
                               {
                                   new { ID = 10, Name = "Line 1" },
                                   new { ID = 7, Name = "Line 2" },
                                   new { ID = 12, Name = "Line 3" },
                                   new { ID = 18, Name = "Line 4" }
                               }.ToList(); 
                
                foreach (var line in lines)
                {
                    /* NEW TabStripItem */                               
                    var tabStripItem = new TabStripItem
                                       {
                                           ItemID = line.ID.ToString(),    
                                           Title = line.Name
                                       };
    
                    TabStrip1.Listeners.TabChange.Handler = "Ext.net.DirectMethods.LoadActiveTab(tab.id);"; 
                    TabStrip1.Items.Add(tabStripItem);
                }
            }
        }
    
    
        [DirectMethod]
        public void LoadActiveTab(string lineId)
        {
            X.Msg.Notify("Server Side, Tab clicked: ", lineId).Show();
        } 
        
    </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:TabStrip ID="TabStrip1" runat="server" />
        </form>
    </body>
    </html>

    Quote Originally Posted by Fahd View Post
    That works...

    Thank you very much...
    Last edited by Fahd; May 31, 2012 at 6:03 PM. Reason: Updated the title

Similar Threads

  1. Replies: 5
    Last Post: Jun 22, 2012, 2:47 PM
  2. Replies: 2
    Last Post: May 15, 2012, 11:47 AM
  3. [CLOSED] creating tabStrip in javascript
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 10, 2012, 5:58 PM
  4. Replies: 0
    Last Post: Mar 27, 2012, 10:01 AM
  5. Replies: 1
    Last Post: Jan 08, 2011, 1:00 AM

Posting Permissions