Button inside Update Panel is not triggered, in asp.net

前端 未结 1 437
失恋的感觉
失恋的感觉 2021-01-20 19:18

<         


        
相关标签:
1条回答
  • 2021-01-20 19:42

    Change the UpdatePanel's ChildrenAsTriggers property to true. This will cause any postbacks triggered by the UpdatePanel's child elements to update its content.

    EDIT: Just realized that btn_Add is a nested control, so you will have to explicitly call it out as an UpdatePanel Trigger. Add the following to your UpdatePanel markup, after the ContentTemplate:

    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btn_Add" /> 
    </Triggers>
    

    EDIT #2: To keep your modal popup from closing when an async postback occurs, move the UpdatePanel inside the panel specified by ModalPopupExtender's PopupControlID:

    <asp:Panel ID="pnlpopup" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
            <ContentTemplate>
                <asp:ListBox ID="lst_allmembers" DataValueField="FirstName" runat="server" />
                <asp:Button ID="btn_Add" runat="server" Text="Add" OnClick="btn_Add_Click" />
                <asp:ListBox ID="lst_grpmembers" runat="server" />
                <asp:Button ID="btn_remove" runat="server" Text="Remove" />
                <asp:Button ID="btnUpdate" CommandName="Update" runat="server" Text="Update" OnClick="btnUpdate_Click" />
                 <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    
    0 讨论(0)
提交回复
热议问题