Using Ext.NET v1.3, I need to ADD a User Control to each Tab dynamically...

Hybrid View

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

    Using Ext.NET v1.3, I need to ADD a User Control to each Tab dynamically...

    Hi,
    I am trying to load my existing User Control to each Tab that is creating.

    I tried 'tab.LoadContent' but it doesn't seems to work. Please help.

    .cs
                var controller = new FormDetailsController();
                var lines = controller.GetLinesForBakery(CurrentBakeryId);
    
                int[] index = {1};
                foreach (var tab in lines.Select(line => new Panel
                                                               {
                                                                   ID = "TabBreadLine" + index[0], 
                                                                   AutoHeight = true, 
                                                                   Title = line.Description.Trim(),
                                                                   Padding = 6
                                                               }))
                {
                    tab.LoadContent(new LoadConfig("C:/DATA/Projects/Wildcat_v2/Web/UserControls/Runs.ascx", LoadMode.IFrame, true));
                    tab.Html = DateTime.Now.ToLongTimeString() + " Tab: " + index[0]; //Test 
                    tab.Render(TabBakeryLines, RenderMode.AddTo);
                    index[0]++;
                }
    .aspx
      <ext:TabPanel ID="TabBakeryLines" runat="server" AutoHeight="true" StyleSpec="padding-left:2px;" />
  2. #2

    ONLY the First Tab get loaded with my User Control, the rest are blank...

    Hi,
    Lets say I have four (4) lines, ONLY the first Tab loads up my User Control and the rest and just blank with my updated coded below.

    .cs
                        var lines = controller.GetLinesForBakery(CurrentBakeryId);
    
                        int[] index = {1};
                        foreach(var line in lines)
                        {
                            //* NEW Tab Panel */
                            var tab = new Panel
                            {
                                ID = "TabBreadLine" + index[0],
                                AutoHeight = true,
                                Title = line.Description.Trim(),
                                Padding = 6
                            };
    
                            var userControl = (UserControl)LoadControl("~/UserControls/Runs.ascx");
                            userControl.ID = "LineUserControl" + index[0];
                            tab.ContentControls.Add(userControl);
                            TabBakeryLines.Items.Add(tab);
                            index[0]++;
                        }
                        TabBakeryLines.Render();


    Quote Originally Posted by RonaldR View Post
    Hi,
    I am trying to load my existing User Control to each Tab that is creating.

    I tried 'tab.LoadContent' but it doesn't seems to work. Please help.

    .cs
                var controller = new FormDetailsController();
                var lines = controller.GetLinesForBakery(CurrentBakeryId);
    
                int[] index = {1};
                foreach (var tab in lines.Select(line => new Panel
                                                               {
                                                                   ID = "TabBreadLine" + index[0], 
                                                                   AutoHeight = true, 
                                                                   Title = line.Description.Trim(),
                                                                   Padding = 6
                                                               }))
                {
                    tab.LoadContent(new LoadConfig("C:/DATA/Projects/Wildcat_v2/Web/UserControls/Runs.ascx", LoadMode.IFrame, true));
                    tab.Html = DateTime.Now.ToLongTimeString() + " Tab: " + index[0]; //Test 
                    tab.Render(TabBakeryLines, RenderMode.AddTo);
                    index[0]++;
                }
    .aspx
      <ext:TabPanel ID="TabBakeryLines" runat="server" AutoHeight="true" StyleSpec="padding-left:2px;" />
  3. #3
    Hi,
    I believe the problem lies when I tried to load ALL the tabs with the same User Control and the ID are the same...

    Example, "A Control with an ID of "GridPanel1" has already been initialized. Please ensure that all Controls have a unique id."

    How do I Load & Upload a User Control when the user selects a different Tab ??

    Quote Originally Posted by RonaldR View Post
    Hi,
    Lets say I have four (4) lines, ONLY the first Tab loads up my User Control and the rest and just blank with my updated coded below.

    .cs
                        var lines = controller.GetLinesForBakery(CurrentBakeryId);
    
                        int[] index = {1};
                        foreach(var line in lines)
                        {
                            //* NEW Tab Panel */
                            var tab = new Panel
                            {
                                ID = "TabBreadLine" + index[0],
                                AutoHeight = true,
                                Title = line.Description.Trim(),
                                Padding = 6
                            };
    
                            var userControl = (UserControl)LoadControl("~/UserControls/Runs.ascx");
                            userControl.ID = "LineUserControl" + index[0];
                            tab.ContentControls.Add(userControl);
                            TabBakeryLines.Items.Add(tab);
                            index[0]++;
                        }
                        TabBakeryLines.Render();
  4. #4

    In my code behind, I creating an event to fire whenever another TAB becomes ACTIVE, but I get an error below:

    Hey,
    Error Message: "The control with ID 'TabBreadLine1' not found"

    BUT I don't understand why I get this error because I created this control...

    .cs
                        var lines = controller.GetLinesForBakery(CurrentBakeryId);
    
                        int[] index = { 1 };
                        foreach (var line in lines)
                        {
                            //* NEW Tab Panel */
                            var tab = new Panel
                                          {
                                              ID = "TabBreadLine" + index[0],
                                              AutoHeight = true,
                                              Title = line.Description.Trim(),
                                              Padding = 6
                                          };
    
                            if (index[0] == 1)
                            {
                                var userControl = (UserControl)LoadControl("~/UserControls/Runs.ascx");
                                userControl.ID = "LineUserControl" + index[0];
                                tab.ContentControls.Add(userControl);
                            }
    
                            tab.DirectEvents.Activate.Event += UpdateTimeStamp;
                            TabBakeryLines.Items.Add(tab);
                            index[0]++;
                        }
                        TabBakeryLines.Render();
    .cs
            protected void UpdateTimeStamp(object sender, DirectEventArgs e)
            {
                X.Msg.Notify("The Server Time is: ", DateTime.Now.ToLongTimeString()).Show();
            }


    Quote Originally Posted by RonaldR View Post
    Hi,
    I believe the problem lies when I tried to load ALL the tabs with the same User Control and the ID are the same...

    Example, "A Control with an ID of "GridPanel1" has already been initialized. Please ensure that all Controls have a unique id."

    How do I Load & Upload a User Control when the user selects a different Tab ??
  5. #5
    Hi,

    Any chance you could post a full .aspx sample which demonstrates the scenario? Something we could just copy/paste into our testing project and run without having to make modifications to your code.
    Geoffrey McGill
    Founder
  6. #6
    Thanks YOU for the quick response, here you go..

    Basically the goal here is to fire the event when the User Clicks on the TAB... (The time is just a TEST below)

    MY FINAL GOAL:
    Unload the User Control from the first TAB and load it to the ACTIVE TAB, if you can guide me on the second part, please help.
    .cs
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!X.IsAjaxRequest)
                {
                   try
                    {
                        var lines = new List<int>() {1, 2, 3, 4};
    
                        int[] index = { 1 };
                        foreach (var line in lines)
                        {
                            //* NEW Tab Panel */
                            var tab = new Panel
                                          {
                                              ID = "TabBreadLine" + index[0],
                                              AutoHeight = true,
                                              Title = "TabBreadLine" + index[0],
                                              Padding = 6
                                          };
    
                            tab.DirectEvents.Activate.Event += UpdateTimeStamp;
    
                            TabBakeryLines.Items.Add(tab);
                            index[0]++;
                        }
                        TabBakeryLines.Render();
                    }
    
                }
            }
    
            protected void UpdateTimeStamp(object sender, DirectEventArgs e)
            {
                X.Msg.Notify("The Server Time is: ", DateTime.Now.ToLongTimeString()).Show();
            }
    .aspx
        <ext:TabPanel ID="TabBakeryLines" runat="server" AutoHeight="true" EnableTabScroll="true"
            StyleSpec="padding-left:2px;" />

    Click image for larger version. 

Name:	Error.JPG 
Views:	187 
Size:	39.5 KB 
ID:	4247


    Quote Originally Posted by geoffrey.mcgill View Post
    Hi,

    Any chance you could post a full .aspx sample which demonstrates the scenario? Something we could just copy/paste into our testing project and run without having to make modifications to your code.
    Last edited by RonaldR; May 16, 2012 at 4:35 PM. Reason: Attaching an Image of Error

Similar Threads

  1. Replies: 0
    Last Post: May 16, 2012, 11:29 PM
  2. Replies: 2
    Last Post: Dec 08, 2011, 1:00 PM
  3. Replies: 0
    Last Post: May 03, 2010, 4:33 AM
  4. [CLOSED] Add Tab dynamically which contains user control
    By pschojer in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 04, 2009, 1:18 PM
  5. Dynamically loading a user control
    By kene in forum 1.x Help
    Replies: 0
    Last Post: Mar 16, 2009, 7:28 AM

Tags for this Thread

Posting Permissions