为什么我的onchange asp.net组合框没有被调用?

时间:2011-10-05 14:34:27

标签: javascript asp.net vb.net

我不认为我的改变功能被称为......为什么?

Public Sub selCurrentManuf_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selCurrentManuf.SelectedIndexChanged
   Response.Write("<script language='javascript'>alert('"+"oi"+"');</script>")
End Sub   

<asp:DropDownList runat="server" ID="selCurrentManuf"  OnSelectedIndexChanged="selCurrentManuf_SelectedIndexChanged"></asp:DropDownList>

我做错了吗?

1 个答案:

答案 0 :(得分:4)

尝试将AutoPostBack="true"添加到控件标记中;假设您希望它立即执行操作。否则,在以其他方式提交表单之前,事件不会触发。

<asp:DropDownList runat="server" ID="selCurrentManuf" autopostback="true" OnSelectedIndexChanged="selCurrentManuf_SelectedIndexChanged"></asp:DropDownList>