代码之家  ›  专栏  ›  技术社区  ›  Aman

下拉列表选定的更改事件在按钮单击事件时触发

  •  0
  • Aman  · 技术社区  · 15 年前

    我已经在.Net中编写了代码。当我点击按钮,然后在事件下面开火。请帮忙怎么做。

    protected void ddldesignation_SelectedIndexChanged(object sender, EventArgs e)
    {
          Code.
    }
    
    1 回复  |  直到 13 年前
        1
  •  0
  •   Robert Dougan    15 年前

    检查按钮是否在页面的窗体集合中,可以将其用作停止触发下拉列表事件的条件。

    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
        }
    }
    
    推荐文章