【问题标题】:C# dropdownlist change eventC# 下拉列表更改事件
【发布时间】:2011-06-20 17:46:14
【问题描述】:
<asp:DropDownList runat="server" ID="myListDropDown" CssClass="text" OnSelectedIndexChanged="myListDropDown_Change" />

上面有aspx

protected void myListDropDown_Change(object sender, EventArgs e)
        {
            //stuff that never gets hit
        }

我在 myListDropDown 方法上设置了一个断点,但它永远不会被命中。有什么建议吗?

【问题讨论】:

  • 应该是myListDropDown_SelectedIndexChanged()。见这里msdn.microsoft.com/en-us/library/…
  • @Rahul 事件处理程序的名称无关紧要。
  • @Rahul myListDropDown_SelectedIndexChanged() 可能更有意义,但没关系。不过感谢您的参与。

标签: c# events


【解决方案1】:

DropDownList 控件的AutoPostBack 属性设置为true

<asp:DropDownList AutoPostBack="true" runat="server" ID="myListDropDown" 
                CssClass="text" OnSelectedIndexChanged="myListDropDown_Change" />

【讨论】:

    【解决方案2】:

    DropDownList 的 Autopostback 属性需要设置为 'true'。

    【讨论】:

      猜你喜欢
      • 2015-12-25
      • 2017-03-21
      • 2014-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多