[英]DropDownList's OnSelectedIndexChanged Does Not Fire
I created these DropDownList
s: 我创建了以下
DropDownList
:
<asp:DropDownList CssClass="ComboBoxes" ID="UserComboBox" runat="server" OnSelectedIndexChanged="UserComboBoxSelected"/>
<asp:DropDownList CssClass="ComboBoxes" ID="ShiftComboBox" runat="server"/>
I have this in the code-behind: 我在后面的代码中有这个:
protected void UserComboBoxSelected(object sender, EventArgs e)
{
// ...
}
However, it never fires when I select items in UserComboBox
. 但是,当我在
UserComboBox
选择项目时,它永远不会触发。 What am I doing wrong? 我究竟做错了什么?
You have to set [AutoPostBack][1]
to true for firing event on server side code behind file. 您必须将
[AutoPostBack][1]
为true,以触发文件后面的服务器端代码上的事件。
<asp:DropDownList CssClass="ComboBoxes" ID="UserComboBox" runat="server" AutoPostBack="true" OnSelectedIndexChanged="UserComboBoxSelected"/>
Gets or sets a value indicating whether a postback to the server automatically occurs when the user changes the list selection, MSDN .
获取或设置一个值,该值指示当用户更改列表选择MSDN时是否自动发生回发到服务器。
<asp:DropDownList
CssClass="ComboBoxes"
ID="UserComboBox"
runat="server"
OnSelectedIndexChanged="UserComboBoxSelected"
AutoPostBack="true" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.