单击按钮时如何显示ModalPopup?

时间:2013-03-12 06:37:38

标签: 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="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>

代码背后

           protected void btnShowPopup_Click(object sender, EventArgs e)
            {      
              ModalPopupContextInfo.Show();
            }

这不起作用。

2 个答案:

答案 0 :(得分:0)

您忘记定义imgClose控件,您在ModalPopupExtender中将其用作CancelControlID。

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

这就是你的扩展器无效的原因。

答案 1 :(得分:0)

您还需要为Model Popup Extender设置活动索引。主要是

ASPX页面:

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

“ajaxToolkit:ModalPopupExtender ID =”ModalPopupExtender1“BackgroundCssClass =”ModalPopupBG“  runat =“server”TargetControlID =“Button1”CancelControlID =“btnCancel1”PopupControlID =“Panel1”Drag =“true”PopupDragHandleControlID =“PopupHeader”

然后

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

/ ASP:查看

/ ASP:多视点

C#

protected void Page_Load(object sender,EventArgs e)

    {
        try
        {
            if (!IsPostBack)
            {
               ModalPopupContextInfo.ActiveViewIndex = 0;
            }
        }
     }

它的工作原理......很好......如果还想要一些......帮助......请给我一个......