C#下拉列表更改事件

Bla*_*ers 19 c# events

<asp:DropDownList runat="server" ID="myListDropDown" CssClass="text" OnSelectedIndexChanged="myListDropDown_Change" />
Run Code Online (Sandbox Code Playgroud)

上面有aspx

protected void myListDropDown_Change(object sender, EventArgs e)
        {
            //stuff that never gets hit
        }
Run Code Online (Sandbox Code Playgroud)

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

Bal*_*a R 30

将控件的AutoPostBack属性设置DropDownListtrue.

<asp:DropDownList AutoPostBack="true" runat="server" ID="myListDropDown" 
                CssClass="text" OnSelectedIndexChanged="myListDropDown_Change" />
Run Code Online (Sandbox Code Playgroud)


Squ*_*eMe 5

DropDownList的Autopostback属性需要设置为"true".