how to add controls dynamically

  1. #1

    how to add controls dynamically

    hello,
    I want to add control at run time. I have following code which is not working. so please tell me if i am missing something.

    when user will click preview button following code will execute. the label should be create and added to panel1 which is present on the window(winFormGeneration), and we will make the Window visiable.

    protected void btnPreview_Click(object sender, DirectEventArgs e)
    {
            Ext.Net.Label lable1 = new Ext.Net.Label();
            lable1.ID = "exam";
            lable1.Text = "examNumber";
            Panel1.Controls.Add(lable1);
            WinFormGeneration.Show();        
    }
    Last edited by geoffrey.mcgill; Oct 26, 2010 at 8:17 PM. Reason: please use [CODE] tags
  2. #2
    Hi,

    protected void btnPreview_Click(object sender, DirectEventArgs e)
    {
    Ext.Net.Label lable1 = new Ext.Net.Label();
    lable1.ID = "exam";
    lable1.Text = "examNumber";
    Panel1.Items.Add(lable1);
    label1.Render();
    WinFormGeneration.Show(); 
    }

Similar Threads

  1. Dynamically adding Controls to WebUserControl
    By bright in forum 1.x Help
    Replies: 8
    Last Post: Apr 27, 2012, 6:34 PM
  2. Iteration on dynamically added controls
    By kutlu in forum 1.x Help
    Replies: 1
    Last Post: Jan 02, 2011, 7:14 PM
  3. Dynamically created controls cookbooks
    By arodier in forum 1.x Help
    Replies: 15
    Last Post: May 07, 2010, 7:12 PM
  4. How to dynamically load user controls?
    By zikr in forum 1.x Help
    Replies: 0
    Last Post: Jan 23, 2009, 9:35 PM
  5. [CLOSED] Dynamically adding controls to a tav
    By riccardosarti in forum 1.x Help
    Replies: 3
    Last Post: Sep 24, 2008, 9:49 AM

Posting Permissions