Ajax ModalPopupExtender无法正常工作

时间:2018-07-10 03:47:09

标签: asp.net ajax asp.net-ajax

我正在使用Ajax ModalPopupExtender按下按钮时弹出一个窗口? 弹出窗口没有显示..请帮助我..我尝试的代码:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>       
                                    </div>
                                    <div class="button highlight">
 <asp:Button ID="btnCountry" runat="server" CssClass="PopUp_" Text="..." />
                                    </div>
  <ajax:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="btnCountry" PopupControlID="Pan2" BackgroundCssClass="Background" CancelControlID="btnCountryClose">
      </ajax:ModalPopupExtender>
      <asp:Panel ID="Pan2" runat="server" CssClass="Popup" align="center" style="display:none">
                     <table width="310px">
                         <tr>
                             <td>
                                 <asp:Label Text="Country" runat="server"></asp:Label>
                             </td>
                             <td>
                                 <asp:TextBox ID="TxtCountryPopUp" runat="server" Font-Size="14px" ClientIDMode="Static" MaxLength="30"></asp:TextBox>
                             </td>
                         </tr>
                     </table>
                     <br />
 <div style="display:table-row; width:100%; height:30px;">
            <div style="display:table-cell; width:16%;color:#d7bfd7" class="lblCaption_N">Country</div>
            <div class="DE_area" style="width:145px">
                 <asp:Button ID="BtnSaveCountry" runat="server" CssClass="submit-but" Text="Save" OnClick="BtnSaveCountry_Click" />
                         <asp:Button ID="btnCountryClose" CssClass="submit-but" runat="server" Text="Close" />
  </div>
       </div>
              </asp:Panel> 

1 个答案:

答案 0 :(得分:0)

您需要通过将以下行放在@PageDirective下方来注册AJAX控制工具包库

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" 
TagPrefix="cc1"%>


<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<asp:Button ID="btnShow" runat="server" Text="Show Modal Popup" />

<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1" 
TargetControlID="btnShow"
CancelControlID="btnClose" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>

<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center" style = 
"display:none">Example<br />
 <asp:Button ID="btnClose" runat="server" Text="Close" />

</asp:Panel>