protected override void CreateChildControls()
{
base.CreateChildControls();
LinkButton goButton;
goButton = new LinkButton();
goButton.ID = "butGo";
goButton.Text = "Go";
goButton.Command += new CommandEventHandler(goButton_Command);
goButton.Click += new EventHandler(goButton_Click);
goButton.CausesValidation = false;
Controls.Add(goButton);
UpdatePanel updatePanel;
updatePanel = new UpdatePanel();
updatePanel.ID = "upUpdatePanel";
updatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
updatePanel.ChildrenAsTriggers = false;
AsyncPostBackTrigger t = new AsyncPostBackTrigger();
t.EventName = "Command";
t.ControlID = goButton.ID;
updatePanel.Triggers.Add(t);
Label lb = new Label();
lb.ID = "DT";
lb.Text = "Time";
updatePanel.ContentTemplateContainer.Controls.Add(lb);
Controls.Add(updatePanel);
}
private void goButton_Command(object sender, CommandEventArgs e)
{
Control ctl = sender as Control;
UpdatePanel up = ctl.NamingContainer.FindControl("upUpdatePanel") as UpdatePanel;
Label lbl = up.ContentTemplateContainer.FindControl("DT") as Label;
lbl.Text = DateTime.Now.ToString();
}