按钮单击更新面板内部导致回发

时间:2013-06-25 09:05:29

标签: c# asp.net asynchronous

我希望在更新面板内单击按钮时返回页面回发。 我附上你的代码。我想要回发的按钮是btnUpdate。我的目标是在模态弹出窗口内完成操作,在模态弹出窗口之外的gridview进行更新。 主要问题是我在同一个模式弹出窗口中有多个内容占位符,我想运行异步。

 <asp:Panel ID="Panel1" runat="server"></asp:Panel>
    <asp:Button  ID="btnShowPopup" runat="server" style="display:none" /> 

              <asp:ModalPopupExtender ID="ModalPopupExtender1" PopupDragHandleControlID="Panel1" RepositionMode="None" runat="server" PopupControlID="pnlpopup" 
TargetControlID="btnShowPopup" CancelControlID="btnCancel"
    DropShadow="true"   
 BackgroundCssClass="modalBackground">

        </asp:ModalPopupExtender>

        <asp:Panel ID="pnlpopup" runat="server" BackColor="LightGray" style="display: none"
             CssClass="modalPopup" Width="650px" >
               <asp:UpdatePanel ID="UpdatePanel3" UpdateMode="Conditional" runat="server">
                                <ContentTemplate>
             <asp:PlaceHolder ID="PlaceHolder1" Visible="false" runat="server">
 <asp:Button ID="btnUpdate" ValidationGroup="r" runat="server" Height="30px" Width="160px" CommandName="Update" 
                                          OnClick="btnUpdate_Click" Text="Save"  
                                          Visible="False" />

                                      <asp:Button ID="Button5" runat="server" ValidationGroup="r" Height="30px" Width="160px" onclick="Button5_Click" Text="Save" 
                                          Visible="False" />
</asp:PlaceHolder>
                          <asp:PlaceHolder ID="PlaceHolder2" Visible="false" runat="server">
                     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                     <ContentTemplate>
<asp:Button ID="btn1" ValidationGroup="a" runat="server" Height="30px" Width="160px" CommandName="Update" 
                                          OnClick="btn1_Click" Text="Save"  
                                          Visible="False" />
                     </ContentTemplate>
                     </asp:UpdatePanel>
                        </asp:PlaceHolder>

1 个答案:

答案 0 :(得分:0)

使用

              <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                        <%--Content that you want to update on Button1 or Button2--%>//write content that you want to update
                        </ContentTemplate>
                        <Triggers>
//trigger asyn event of control and it's event 
                        <%--asp:AsyncPostBackTrigger  events of control on which this content should update--%>
                            <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
                            <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>

了解更多信息http://msdn.microsoft.com/en-us/library/bb399001%28v=vs.100%29.aspx