首页 > 解决方案 > 如何在没有回发的情况下使用 OnselectedIndexChange?

问题描述

我有 2 个下拉列表,我需要第一个(ActionList)来控制第二个(JustificationList)的值。问题是当我在第一个下拉列表中包含 Autopostback 时,我的整个页面都刷新了。

我尝试使用 updatePanel 和触发器,但它仍然不起作用。没有错误,只是刷新发生在 Index Changed 上。

<asp:UpdatePanel ID="UpdatePanel2" runat="server">             
    <ContentTemplate>
        <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
        <input class="form-control" id="myInput" type="text"
            placeholder="Search.." autocomplete="off" style="width: 80%; 
            margin-left: 25px; margin-bottom: 10px;">

        <asp:Label Text="Update Selection" runat="server" Style="width: 80%; 
            margin-left: 25px; margin-bottom: 10px; color: white"></asp:Label>

        <asp:DropDownList ID="ActionList" runat="server" AutoPostBack="true" 
            CSSclass="form-control" style="width: 80%; margin-left: 25px; 
            margin-bottom: 10px;" OnSelectedIndexChanged="JustificationData">
        </asp:DropDownList>
        <asp:DropDownList ID="JustificationList" runat="server" 
            CSSclass="form-control"  style="width: 80%; margin-left: 25px; 
            margin-bottom: 10px;">
        </asp:DropDownList>    
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ActionList" />
    </Triggers>
</asp:UpdatePanel>

请问我做错了什么?

标签: c#asp.netpostback

解决方案


推荐阅读