2010-09-24 148 views
0

我已经在.Net中编写代码。当我点击Buttun,然后在事件下方发射。请帮助如何做到这一点。下拉选择更改事件触发按钮单击事件

protected void ddldesignation_SelectedIndexChanged(object sender, EventArgs e) 
{ 
     Code. 
} 
+0

如果您已经“写入代码”还剩下要做什么?这是一个猜测tho - 在下拉列表中设置autopostback = true。 – RPM1984 2010-09-24 05:41:55

回答

0

检查按钮是否在页面的表单集合中,可以使用该按钮作为停止下拉列表事件触发的条件。

protected void ddldesignation_SelectedIndexChanged(object sender, EventArgs e) 
{ 
    bool runEventCode = true; 
    foreach (string ctl in Page.Request.Form) 
    { 
     Control c = Page.FindControl(ctl); 
     if (c is Button) 
     { 
      runEventCode = false; 
      break; 
     } 
    } 

    if (runEventCode) 
    { 
     //Event handler code here 
    } 
}