2013-06-25 109 views
1

我想在單擊更新面板內的按鈕時導致頁面回發。 我附上你我的代碼。我想讓帖子返回的按鈕是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> 

回答

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

相關問題