DropDownList's OnSelectedIndexChanged Does Not Fire
本文关键字:Does Not Fire OnSelectedIndexChanged DropDownList | 更新日期: 2023-09-27 18:20:50
我创建了这些DropDownList
s:
<asp:DropDownList CssClass="ComboBoxes" ID="UserComboBox" runat="server" OnSelectedIndexChanged="UserComboBoxSelected"/>
<asp:DropDownList CssClass="ComboBoxes" ID="ShiftComboBox" runat="server"/>
我在后面的代码中有这个:
protected void UserComboBoxSelected(object sender, EventArgs e)
{
// ...
}
但是,当我在UserComboBox
中选择项目时,它从不触发。我做错了什么?
您必须将[AutoPostBack][1]
设置为true才能在服务器端代码隐藏文件上触发事件。
<asp:DropDownList CssClass="ComboBoxes" ID="UserComboBox" runat="server" AutoPostBack="true" OnSelectedIndexChanged="UserComboBoxSelected"/>
获取或设置一个值,该值指示是否回发到服务器当用户更改列表选择时,MSDN会自动发生。
<asp:DropDownList
CssClass="ComboBoxes"
ID="UserComboBox"
runat="server"
OnSelectedIndexChanged="UserComboBoxSelected"
AutoPostBack="true" />