日期:2014-05-18 浏览次数:20430 次
public partial class test_updatepaneltest : System.Web.UI.Page { protected void show_it(object sender, EventArgs e) { ScriptManager my_script = new ScriptManager(); panel_place.Controls.Add(my_script); UpdatePanel mypanel = new UpdatePanel(); panel_place.Controls.Add(mypanel); Button show_btn = new Button(); show_btn.ID = "button1"; show_btn.Text = "inside_btn at "+DateTime.Now.Second.ToString(); mypanel.ContentTemplateContainer.Controls.Add(show_btn); Button show_btn2 = new Button(); show_btn2.ID = "button2"; show_btn2.Text = "outside_btn at " + DateTime.Now.Second.ToString(); showplace.Controls.Add(show_btn2); } protected void Page_Load(object sender, EventArgs e) { Button show_updatepanel = new Button(); show_updatepanel.Click += new EventHandler(show_it); show_updatepanel.Text = "点击这里!"; showplace.Controls.Add(show_updatepanel); } }
<form id="form1" runat="server"> <div> <asp:Label ID="showplace" runat="server"></asp:Label><br /> <asp:Label ID="panel_place" runat="server"></asp:Label> </div> </form>