【问题标题】:SelectedIndexChanged event without autopostback is true没有自动回发的 SelectedIndexChanged 事件为真
【发布时间】:2014-04-17 12:11:45
【问题描述】:

在我的应用程序中,我使用列表框作为多选模式。我需要在不使用的情况下为列表框触发 SelectedIndexChanged event

autopostback(AutoPostBack=True)

在 C# 中。我怎样才能做到这一点?

【问题讨论】:

标签: c# asp.net


【解决方案1】:

将您的列表框带入更新面板,如下所示:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel runat="server">
        <ContentTemplate>
            <asp:ListBox ID="ListBox1" SelectionMode="Multiple" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" AutoPostBack="true" runat="server">
                <asp:ListItem Text="text 1" Value="0"></asp:ListItem>
                <asp:ListItem Text="text 2" Value="1"></asp:ListItem>
                <asp:ListItem Text="text 3" Value="2"></asp:ListItem>
                <asp:ListItem Text="text 4" Value="3"></asp:ListItem>
                <asp:ListItem Text="text 5" Value="4"></asp:ListItem>
            </asp:ListBox>
        </ContentTemplate>
    </asp:UpdatePanel>

【讨论】:

  • Asker 提到他不想要 AutoPostBack="true"
猜你喜欢
  • 2012-01-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-15
  • 2011-07-04
  • 2013-05-23
相关资源
最近更新 更多