Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 单击按钮时如何显示ModalPopup?_C#_Asp.net_Ajaxcontroltoolkit_Modalpopupextender - Fatal编程技术网

C# 单击按钮时如何显示ModalPopup?

C# 单击按钮时如何显示ModalPopup?,c#,asp.net,ajaxcontroltoolkit,modalpopupextender,C#,Asp.net,Ajaxcontroltoolkit,Modalpopupextender,当我点击一个按钮时,我必须显示一个模式弹出窗口 ASPX代码: <section> <asp:Button ID="btnShowPopup" runat="server" Text="EditContextMenu" Visible="true" OnClick="btnShowPopup_Click" /> <ajax:ModalPopupExtender ID="ModalPopupContextInfo" runat="s

当我点击一个按钮时,我必须显示一个模式弹出窗口

ASPX代码

   <section>

       <asp:Button ID="btnShowPopup" runat="server"  Text="EditContextMenu" Visible="true" OnClick="btnShowPopup_Click" />

     <ajax:ModalPopupExtender ID="ModalPopupContextInfo" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlpopupContextInfo"
           CancelControlID="imgClose" BackgroundCssClass="modalBackground">
       </ajax:ModalPopupExtender>

       <asp:Panel ID="pnlpopupContextInfo" runat="server" BackColor="White" Height="560px" Width="400px" Style="display: none" >
           <div class="contextMenu_edit" >
           <div class="context_menu">

         <p>Port</p>
          <asp:TextBox ID="txtCMEditPort" runat="server" MaxLength="10" Width="131px" TabIndex="1"></asp:TextBox>

         <div class="clear"></div>

         <p>ProformaETA</p>
         <asp:TextBox ID="txtCMEditProformaETA" runat="server" MaxLength="10" Width="131px" TabIndex="1"></asp:TextBox>
         <asp:ImageButton ID="imgbtnCMEditProformaETA" runat="server" ImageUrl="~/image_repository/calendarIcon.jpg" />
         <ajax:CalendarExtender ID="ajaxcalProfrmaETA" runat="server" TargetControlID="txtCMEditProformaETA" PopupButtonID="imgbtnCMEditProformaETA" Format="dd-MMM-yyyy"></ajax:CalendarExtender>

         <div class="clear"></div>

          <p>ProformaETD</p>
         <asp:TextBox ID="txtCMEditProformaETD" runat="server" MaxLength="10" Width="131px" TabIndex="1"></asp:TextBox>
         <asp:ImageButton ID="imgbtnCMEditProformaETD" runat="server" ImageUrl="~/image_repository/calendarIcon.jpg" />
         <ajax:CalendarExtender ID="ajaxcalProfrmaETD" runat="server" TargetControlID="txtCMEditProformaETD" PopupButtonID="imgbtnCMEditProformaETD" Format="dd-MMM-yyyy"></ajax:CalendarExtender>
    </div>
    </div>
       </asp:Panel>
</section>

这不起作用。

您忘记定义imgClose控件,在ModalPopupXtender中用作CancelControlID

<ajax:ModalPopupExtender ID="ModalPopupContextInfo" runat="server"   TargetControlID="btnShowPopup" PopupControlID="pnlpopupContextInfo"
       CancelControlID="imgClose" BackgroundCssClass="modalBackground">


这就是扩展器无法工作的原因。

您还需要为型号Popup extender设置活动索引。主要是它

ASPX页面:

“asp:button id=“Button1”runat=“server”text=“down”cssclass=“FormButton”width=“20%”

“ajaxToolkit:ModalPopupExtender ID=“ModalPopupExtender1”背景csclass=“ModalPopupBG” runat=“server”TargetControlID=“Button1”CancelControlID=“btnCancel1”PopupControlID=“Panel1”Drag=“true”PopupDragHandleControlID=“PopucReader”

然后

“asp:multiview id=“MultiViewExpanse”runat=“server”“ asp:View ID=“ViewInput”runat=“server”

/asp:视图

/asp:多视图

C#

受保护的无效页面加载(对象发送方、事件参数e)

它很有效…很好…如果还需要…帮助。。。。打我

<ajax:ModalPopupExtender ID="ModalPopupContextInfo" runat="server"   TargetControlID="btnShowPopup" PopupControlID="pnlpopupContextInfo"
       CancelControlID="imgClose" BackgroundCssClass="modalBackground">
    {
        try
        {
            if (!IsPostBack)
            {
               ModalPopupContextInfo.ActiveViewIndex = 0;
            }
        }
     }