我動態生成多個Button﹐
button = new Button();
button.Text = dr[0].ToString();
button.CommandArgument=dr[0].ToString();
button.CssClass = "btnLink";
button.Click += new EventHandler(this.link_Click);
panLink.Controls.Add(button);請問我怎樣在link_Click方法中知道是那個Button觸發的
private void link_Click(object sender, System.EventArgs e)
{
Response.Write(((Button)sender).Text);//該方法不行
}
button = new Button();
button.Text = dr[0].ToString();
button.CommandArgument=dr[0].ToString();
button.CssClass = "btnLink";
button.Click += new EventHandler(this.link_Click);
panLink.Controls.Add(button);請問我怎樣在link_Click方法中知道是那個Button觸發的
private void link_Click(object sender, System.EventArgs e)
{
Response.Write(((Button)sender).Text);//該方法不行
}
而是你需要在每次载入页面都要重新计算并且生成这些按钮。所以将计算按钮的代码放到page_load()中。
?search=中文
這種url﹐我在Request.Querystring["search"]時得到是????﹐請問怎樣能得到正確數據
不行就看看是不是字符集的问题。
(button)sender.id确定是哪个按钮触发该事件