I created these DropDownList
s:
<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
. What am I doing wrong?
You have to set [AutoPostBack][1]
to true for firing event on server side code behind file.
<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 .
<asp:DropDownList
CssClass="ComboBoxes"
ID="UserComboBox"
runat="server"
OnSelectedIndexChanged="UserComboBoxSelected"
AutoPostBack="true" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.