2013-03-12 28 views
0

當我點擊一個按鈕,我必須顯示模式彈出如何在點擊按鈕時顯示ModalPopup?

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(); 
      } 

這是行不通的。

回答

0

您忘記了定義imgClose控件,它在ModalPopupExtender中用作CancelControlID。

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

這就是爲什麼你的擴展器無法正常工作。

+0

謝謝...,我已經取代和它的工作 – 2013-03-12 08:43:29

0

此外,您還需要設置模型彈出式擴展器的活動索引。大多它

ASPX頁:

「ASP:按鈕的ID =」 Button1" 的RUNAT = 「服務器」 文本= 「停工時間」 的CssClass = 「FormButton」 寬度= 「20%」

「ajaxToolkit: ModalPopupExtender ID = 「ModalPopupExtender1」 BackgroundCssClass = 「ModalPopupBG」 RUNAT = 「服務器」 的TargetControlID = 「Button1的」 CancelControlID = 「btnCancel1」 PopupControlID = 「Panel1的」 拖放= 「真」 PopupDragHandleControlID = 「PopupHeader」

然後

「ASP:多視點ID =」 MultiViewExpanse 「RUNAT = 」服務器「,」 ASP:查看ID = 「ViewInput」 RUNAT = 「服務器」

/ASP:查看

/ASP:多視點

C#

保護無效的Page_Load(對象發件人,EventArgs的)

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

它工作... ...罰款。如果還是想一些..幫助....平我...

相關問題