2011-04-19 4 views
0

gridview 내에서 modalpopupextender를 사용하여 모달 팝업 창을 여는 "전자 메일"버튼과 "삭제"버튼이 있습니다. 문제는 단추를 클릭 할 때 전자 메일 창이 열리지 만 버튼을 클릭하면 삭제 창이 열리지 않는다는 것입니다. 나는 modalpopupextenders를 같은 방법으로 사용하고있다. 동일한 방식으로 두 개의 ModalPopupExtenders가 사용됩니다. 하나만 작동합니다.

<asp:ButtonField ButtonType="Button" CommandName="Email" Text="Email" /> 
        <asp:ButtonField ButtonType="Button" CommandName="Delete" Text="Delete" /> 

<%-- Email modal--%>  
    <asp:Panel ID="pnlPopupEmail" runat="server" Width="500px" Style="display: none"> 
    <asp:UpdatePanel ID="updPnlEmail" runat="server" UpdateMode="Conditional"> 
    <ContentTemplate> 
    <asp:Button ID="btnShowEmail" runat="server" Style="display: none" /> 
       <ajaxToolkit:ModalPopupExtender ID="mdlPopupEmail" runat="server" TargetControlID="btnShowEmail" 
        PopupControlID="pnlPopupEmail" CancelControlID="btnCancel" BackgroundCssClass="modalBackground" /> 
     <div class="EmailPopup"> 
      <table> 
       <tr> 
        <td> 
         To: 
        </td> 
        <td> 
         <asp:TextBox ID="EmailTo" runat="server" Width="350"></asp:TextBox> 
        </td> 
       </tr> 
       <tr> 
        <td> 
         From: 
        </td> 
        <td> 
         <asp:TextBox ID="EmailFrom" runat="server" Width="350"></asp:TextBox> 
        </td> 
       </tr> 
       <tr> 
        <td> 
         Subject: 
        </td> 
        <td> 
         <asp:TextBox ID="Subject" runat="server" Width="350"></asp:TextBox> 
        </td> 
       </tr> 
       <tr> 
        <td></td> 
         <td> <asp:TextBox ID="EmailMessageBox" Width="350" Height="150" runat="server" TextMode="MultiLine" Wrap="true"></asp:TextBox> 
        </td> 
       </tr> 
       <tr> 
        <td> 
        </td> 
        <td> 
         <asp:LinkButton ID="SendBtn" runat="server" OnClick="SendBtn_Clicked" Text="Send" /> 
         <asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" /> 
        </td> 
        <td> 
         <asp:Label ID="theID" runat="server" Visible="false"></asp:Label> 
        </td> 
       </tr> 
       </table> 
     </div> 

    </ContentTemplate> 
    </asp:UpdatePanel> 
    </asp:Panel> 
    <%-- -----end email modal--%> 
    <%-- Start Delete Confirmation Modal --%> 
    <asp:Panel ID="DelConfirmPanel" runat="server" Width="500px" Style="display: none"> 
     <asp:UpdatePanel ID="DelConfirmUpdatePanel" runat="server" UpdateMode="Conditional"> 
      <ContentTemplate> 
      <asp:Label ID ="TESTLabel" runat="server" Text="Are you sure?" ></asp:Label> 
       <asp:Button ID="DelModalButton" runat="server" Style="display: none" /> 
       <ajaxToolkit:ModalPopupExtender ID="modalPopUpDelConfirm" runat="server" TargetControlID="DelModalButton" 
        PopupControlID="DelConfirmPanel" CancelControlID="DeleteCancel" BackgroundCssClass="modalBackground" /> 
       <div class="DeletePopup"> 
        <asp:LinkButton ID="DelConfirmedButton" runat="server" OnClick="DeleteConfirmation_Clicked" 
         Text="Delete" /> 
        <asp:LinkButton ID="DeleteCancel" runat="server" Text="Cancel" CausesValidation="false" /> 
       </div> 
      </ContentTemplate> 
     </asp:UpdatePanel> 
    </asp:Panel> 
    <%-- End Delete Confirmation Modal --%> 
</div> 

그런 다음 코드 숨김에서 나는 명령 이름을 확인하고 updatepanel을 업데이트하고 modalpopupextender을 표시하는 방법이있다.

protected void btn_Clicked(object sender, GridViewCommandEventArgs e) 
{ 

    if (e.CommandName == "Email") 
    { 
     // a bunch of stuff that I am leaving out but is just changing fields in the 
     //table withing the modal popup 
     updPnlEmail.Update(); 
     mdlPopupEmail.show(); 
    } 

    if (e.CommandName.Equals("Delete")) 
    { 
     int index = Convert.ToInt32(e.CommandArgument); 
     String id = gvReservations.DataKeys[index].Value.ToString(); // get id 
     try 
     { 
      DelConfirmUpdatePanel.Update(); 
      modalPopUpDelConfirm.Show(); 
     } 
     catch (Exception ex) 
     { 
      throw new Exception(ex.Message); 
     } 
    } 
} 

다른 아이디어가 아닌 이유는 무엇입니까? 이런 종류의 오류를 디버깅하는 좋은 방법이 있습니까? 어떤 도움을 주셔서 감사합니다!

답변

1

알아 냈어.

<asp:ButtonField ButtonType="Button" CommandName="Delete" Text="Delete" /> 

여기가 문제입니다. "삭제"는 예약 된 명령 이름이라는 것을 알지 못했습니다. 따라서이 버튼을 클릭하면 테이블에서 삭제할 수 없다는 예외가 발생했습니다. 따라서 모달 팝업이 절대 표시되지 않았습니다. 크롬 도구에서 자바 스크립트 콘솔을 열어서 알아 냈습니다.

그래서 수정하기 위해 명령 이름을 다른 것으로 변경했는데 이제는 모든 것이 예상대로 작동합니다.

관련 문제