protected void Page_Load(object sender, EventArgs e)
{ Table tb = new Table();
TableRow tr = null;
TableCell tc = null;
RadioButton rb = null;
Label lb = null;
Button bt = null; tr = new TableRow();
tc = new TableCell();
bt = new Button();
bt.Text = "保 存";
bt.ID = "store";
bt.Click += new System.EventHandler(this.store_clicked);
bt.OnClientClick = "javascript:return confirm('确定要保存吗?')";
tc.HorizontalAlign = HorizontalAlign.Center;
tc.ColumnSpan = 5;
tc.Controls.Add(bt);
tr.Cells.Add(tc);
tb.Rows.Add(tr);
form1.Controls.Add(tb);
}
protected void store_clicked(object sender, EventArgs e)
{
Response.Write("<script>alert('测试成功!')</script>");
}
//为什么不能触发?
{ Table tb = new Table();
TableRow tr = null;
TableCell tc = null;
RadioButton rb = null;
Label lb = null;
Button bt = null; tr = new TableRow();
tc = new TableCell();
bt = new Button();
bt.Text = "保 存";
bt.ID = "store";
bt.Click += new System.EventHandler(this.store_clicked);
bt.OnClientClick = "javascript:return confirm('确定要保存吗?')";
tc.HorizontalAlign = HorizontalAlign.Center;
tc.ColumnSpan = 5;
tc.Controls.Add(bt);
tr.Cells.Add(tc);
tb.Rows.Add(tr);
form1.Controls.Add(tb);
}
protected void store_clicked(object sender, EventArgs e)
{
Response.Write("<script>alert('测试成功!')</script>");
}
//为什么不能触发?
if(!IsPostBack)
{
...
}
为什么不能触发?怎么解决?