public partial class UpdatePanel : System.Web.UI.Page
{
  private Label Label1;
  protected void Page_Load(object sender, EventArgs e)
  {
    UpdatePanel uPanel = new UpdatePanel();
    uPanel.ID = "UpdatePanel1";
    // tworzy etykietę
    Label1 = new Label();
    Label1.ID = "Label1";
    Label1.Text = DateTime.Now.ToString();
    // tworzy przycisk
    Button button1 = new Button();
    button1.ID = "Button1";
    button1.Click += new EventHandler(Button1_Click);
    // tworzy literał
    LiteralControl literal = new LiteralControl("<br><br>");
    // Wstawia kontrolki do UpdatePanel.
    uPanel.ContentTemplateContainer.Controls.Add(Label1);
    uPanel.ContentTemplateContainer.Controls.Add(literal);
    uPanel.ContentTemplateContainer.Controls.Add(button1);
    // Dodaje kontrolkę UpdatePanel do formularza.
      this.Form.Controls.Add(uPanel);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.Label1.Text = DateTime.Now.ToString();
    }
}
