Adding controls to Panel at runtime doesn't update the Panel

  1. #1

    Adding controls to Panel at runtime doesn't update the Panel

    Hi, what's missing on my code to add controls to a Panel during run-time?
    Thanks

    
    <%@ 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">
    
     
    
    <script 
     runat="server">
        protected void 
    Button1_Click(object sender, DirectEventArgs e)
        
    {
            Ext.Net.HyperLink link = new 
    Ext.Net.HyperLink();
            link.Text = 
    DateTime.Now.ToString();
            link.Icon 
    = Icon.Printer;
            
    Panel1.Controls.Add(link);
            
    X.Msg.Notify("Notify", "Control added").Show();
        
    }
    </script>
    
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head 
    runat="server">
        
    <title></title>
    </head>
    <body>
        
    <form id="form1" runat="server">
        
    <div>
            
    <ext:ResourceManager ID="ResourceManager1" 
    runat="server">
            
    </ext:ResourceManager>
            
    <ext:Panel ID="Panel1" runat="server" Height="300" Title="Title" 
    AutoDoLayout="True">
                
    <Items>
                
    </Items>
            
    </ext:Panel>
            <ext:Button 
    ID="Button1" runat="server" 
    Text="Submit">
                
    <DirectEvents>
                    
    <Click 
    OnEvent="Button1_Click"></Click>
                
    </DirectEvents>
            
    </ext:Button>
        </div>
        
    </form>
    </body>
    </html>
  2. #2
    Solution:

    
    link.AddTo(Panel1);
  3. #3
    Quote Originally Posted by paul-2011 View Post
    Solution:

     
    link.AddTo(Panel1);
    But didn't work with inner controls:

    
    protected void Button1_Click(object sender, DirectEventArgs 
    e)
        {
            
    Ext.Net.HyperLink link = new 
    Ext.Net.HyperLink();
            link.Text = 
    DateTime.Now.ToString();
            link.Icon 
    = Icon.Printer;
    
     
            Ext.Net.Panel panel = new 
    Ext.Net.Panel();
            
    link.AddTo(panel);
    
     
            
    panel.AddTo(Panel1);
            
    X.Msg.Notify("Notify", "Control added").Show();
        }
    You must specify an Element for the AddTo mode.
  4. #4
    You should just add the 'link' to the 'panel' .Items collection.

    Then remove the following line:

    link.AddTo(panel);
    Geoffrey McGill
    Founder
  5. #5
    Quote Originally Posted by geoffrey.mcgill View Post
    You should just add the 'link' to the 'panel' .Items collection.

    Then remove the following line:

    link.AddTo(panel);
    What I'm trying to do in this case is to place the link inside a panel and then add the panel to the master panel.

Similar Threads

  1. Replies: 2
    Last Post: Feb 21, 2012, 8:05 AM
  2. Replies: 0
    Last Post: Sep 22, 2010, 10:43 AM
  3. [CLOSED] Adding controls to Panel dinamically are not rendered
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 21, 2009, 7:41 AM
  4. Adding controls to Panel/Accordion
    By vedagopal2004 in forum 1.x Help
    Replies: 4
    Last Post: Jan 21, 2009, 4:17 AM
  5. Replies: 3
    Last Post: Sep 13, 2008, 10:09 AM

Posting Permissions