摘要:[ASP.NET][EventHandler]當事件超過一個時判斷觸發事件
================================================ Alex70386 寫信: | |
|
01 //sender強制轉換型別(這麼想會比較好記 ==> 事件物件實體化)
02
03
04 protected void tbAM_TextChanged(object sender, EventArgs e)
05 {
06 TextBox tb = (TextBox)sender;
07 try
08 {
09 if (tb.ID == "tbAM")
10 {
11 DropDownList ddl1 = (DropDownList)FindControl("ddlMeterial" + tb.ID.Substring(2, 1) + "1");
12 DropDownList ddl2 = (DropDownList)FindControl("ddlMeterial" + tb.ID.Substring(2, 1) + "2");
13 ddl1.Visible = true;
14 ddl2.Visible = true;
15 }
16 }
17 catch
18 {
19 tb.Text = "Error";
20 }
21 }
02
03
04 protected void tbAM_TextChanged(object sender, EventArgs e)
05 {
06 TextBox tb = (TextBox)sender;
07 try
08 {
09 if (tb.ID == "tbAM")
10 {
11 DropDownList ddl1 = (DropDownList)FindControl("ddlMeterial" + tb.ID.Substring(2, 1) + "1");
12 DropDownList ddl2 = (DropDownList)FindControl("ddlMeterial" + tb.ID.Substring(2, 1) + "2");
13 ddl1.Visible = true;
14 ddl2.Visible = true;
15 }
16 }
17 catch
18 {
19 tb.Text = "Error";
20 }
21 }
_______________________________