<asp:ListBox ID="list1" runat="server" Height="200" Style=" margin: 0" OnSelectedIndexChanged="list1_SelectedIndexChanged">
<asp:ListItem Selected="True" Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
</asp:ListBox>
我在updatePanel中有列表框
但是,当我选择某些东西时,它不会触发事件,这是怎么回事?
最佳答案
您需要将AutoPostBack
属性设置为True。那么只有回发发生,并且您选择的索引事件将触发。
<asp:ListBox AutoPostBack="true" ID="yourLIst" runat="server" Height="200" Style=" margin: 0" OnSelectedIndexChanged="yourLIst_SelectedIndexChanged">
关于asp.net - 在selectedindexchanged中的asp.net列表框不会触发事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18227835/