Ajax ModalpopupExtender无法正常工作

时间:2011-10-02 18:39:26

标签: asp.net ajax

我在asp.net中使用的是modelpopupextender,这个代码工作窗口是popup sucessfuly但取消按钮无法正常工作;谁能告诉我为什么?

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



<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>


<asp:Button ID="buttonOpen" runat="server" style="display:none" ></asp:Button>
   <asp:Panel ID="Panel3"  runat="server" BackColor="#99CCFF" Height="269px" Width="350px"      
        style="display:none">

   <table width="100%" style="border:Solid 3px #D55500; width:100%; height:100%" 

 cellpadding="0" cellspacing="0">

  <tr style="background-color:#333399">

   <td colspan="2" style=" height:10%; color:White; font-weight:bold; font-size:larger"          
     align="center">Time Details</td>
</tr>
   <tr>

   <td>
       <asp:Label ID="Label19" runat="server" Text="Time From"></asp:Label>
   </td>
   <td>
       <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
   </td>
  </tr>
   <tr>
   <td>
       <asp:Label ID="Label20" runat="server" Text="Time To"></asp:Label>
   </td>
   <td>
       <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
   </td>
   </tr>
   <tr>
   <td>
       <asp:Label ID="Label21" runat="server" Text="Number of Slots"></asp:Label>
   </td>
   <td>
       <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
   </td>
   </tr>
   <tr>
   <td>
       <asp:Button ID="Button1" runat="server"  Text="Add" />
   </td>
   <td>
       <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
   </td>
   </tr>
   </table>


   </asp:Panel>
   <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"  OnCancelScript="btnCancel" PopupControlID="panel3" TargetControlID="buttonOpen" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>

1 个答案:

答案 0 :(得分:0)

您需要设置CancelControlID属性,而不是OnCancelScript属性(除非您想在单击取消按钮后执行脚本)。因此,对于您的方案,请执行以下操作:

 <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"  CancelControlID="btnCancel" PopupControlID="panel3" TargetControlID="buttonOpen" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>