Creating updatepanels at runtime?

Last post 10-08-2007 6:57 AM by Jin-Yu Yin - MSFT. 3 replies.

Sort Posts:

  • Creating updatepanels at runtime?

    10-03-2007, 1:57 PM
    • Member
      point Member
    • martinj100
    • Member since 10-02-2007, 8:53 PM
    • Posts 1
    We're writing an app where we need to create a number of tables at runtime which need to be in updatepanels. Being an Ajax newbie I tried having a function in a codebehind generate some HTML/ASP that had the updatepanels in it, but obviously this didn't work.

    Unfortunately I can't put all the tables in one big updatepanel as part of each is a video window that I don't want to restart whenever the timer for the panel triggers.

    Just in case this wasn't clear, what I'm trying to do is create a variable number of update panels at runtime. Any ideas how to go about doing this? I'm sure there's a really simple solution but I haven't been able to figure it out.

    Thanks - James
  • Re: Creating updatepanels at runtime?

    10-03-2007, 2:13 PM
    • Star
      8,978 point Star
    • dwhite
    • Member since 02-08-2007, 2:25 PM
    • Bristol, CT
    • Posts 1,422
  • Re: Creating updatepanels at runtime?

    10-03-2007, 11:21 PM

    protected override void OnInit(EventArgs e)
            {

                UpdatePanel updatePanel = new UpdatePanel();
                //updatePanel.ContentTemplateContainer.Controls.Add(linkButton); if want to add control in UpdatePanel
                form1.Controls.Add(updatePanel);
                base.OnInit(e);
            }

    http://blogs.msdn.com/mikeormond/archive/2007/03/15/dynamically-adding-an-updatepanel-to-your-page.aspx

    http://asp.net/AJAX/Documentation/Live/mref/C_System_Web_UI_UpdatePanel_ctor.aspx

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Creating updatepanels at runtime?

    10-08-2007, 6:57 AM
    Answer

    Hi,

    See my reply to this post Is it possible to add a ScriptManager and/or UpdatePanel to a MasterPage from a ContentPage dynaically?

    protected void Page_PreInit(object sender, EventArgs e)
        {
            HtmlForm form1 = (HtmlForm)Master.FindControl("form1");
            ScriptManager sm = new ScriptManager();
            sm.ID = "ScriptManager1";
            form1.Controls.AddAt(0, sm);
           
            UpdatePanel panel = new UpdatePanel();
            panel.ID = "upMaster";
            UserControl uc = ((UserControl)Master.FindControl("uc1"));
            panel.ContentTemplateContainer.Controls.Add(uc);
            form1.Controls.Add(panel);
        }

    Best Regards,

    Sincerely,
    Jin-Yu Yin
    Microsoft Online Community Support
Page 1 of 1 (4 items)