簡體   English   中英

ModalPopupExtender不回發

[英]ModalPopupExtender does not postback

我在此頁面中有一個ModalPopupExtender。 現在,顯示為ModalPopup的面板具有2個按鈕,即“邀請”和“取消”。 我的問題是,當我單擊任何一個按鈕時都不會發生回發,並且我無法運行服務器端代碼。

當我單擊“邀請”按鈕時,它只是隱藏了ModalPopupExtender控件,什么也不做!

    <asp:ModalPopupExtender ID="mpeInviteFriend" runat="server"
  TargetControlID="lbInvite" PopupControlID="pnlInviteFriend"
  OkControlID="btnInvite" CancelControlID="btnCancel"
  BackgroundCssClass="diabledBackground" Y="100"></asp:ModalPopupExtender>

 <asp:Panel ID="pnlInviteFriend" runat="server">
  <div class="popUpBoxBackground" style="height:230px; width: 400px">
   <div class="popUpBox">
    <div class="popUpHeader">
     <b>Invite a Friend</b>
    </div>
    <div class="popUpBody" style="height:210px">
     <div style="padding: 10px">
      <table cellpadding="0" cellspacing="0" border="0" width="100%">
       <tr>
        <td>You have chosen to invite your friend to join this community.</td>
       </tr>
       <tr>
        <td style="padding: 8px 0px 0px 0px">Email address of your friend:</td>
       </tr>
       <tr>
        <td style="padding: 4px 0px 5px 0px" align="right">
         <asp:TextBox ID="TextBox1" runat="server" 
          TextMode="MultiLine" CssClass="inputTextbox"
          Width="99%" Height="28px"></asp:TextBox>
         <span class="smallInfoText" style="color: #000">In case you want to invite more than 1 friend, separate their mail id with a ;</span>
        </td>
       </tr>
       <tr>
        <td style="padding: 4px 0px 0px 0px">Would you like to add a personal note?</td>
       </tr>
       <tr>
        <td style="padding: 4px 0px 5px 0px" align="right">
         <asp:TextBox ID="txtInvitationText" runat="server" 
          TextMode="MultiLine" CssClass="inputTextbox"
          Width="99%"></asp:TextBox>
         <span class="smallInfoText" style="color: #000">If not then leave it blank and we will take care of the note : )</span>
        </td>
       </tr>
       <tr>
        <td align="right">
         <asp:Button ID="btnInvite" runat="server" OnClick="btnInvite_Click" Text="Invite" style="margin-right: 10px" Width="60px" />
         <asp:Button ID="btnCancel" runat="server" OnClick="btnCancel_Click" Text="Cancel" Width="60px" />
        </td>
       </tr>
      </table>
     </div>
    </div>
   </div>
  </div>
 </asp:Panel>

請幫忙。

謝謝。

刪除標記的這一部分:

OkControlID="btnInvite" CancelControlID="btnCancel"

評論后更新:

在客戶端的初始化階段,執行以下代碼:

    if (this._OkControlID) {
        this._okHandler = Function.createDelegate(this, this._onOk);
        $addHandler($get(this._OkControlID), 'click', this._okHandler);
    }

因此,基本上,它將為_onOK函數創建一個處理程序:

_onOk: function(e) {
    /// <summary>
    /// Handler for the modal dialog's OK button click
    /// </summary>
    /// <param name="e" type="Sys.UI.DomEvent">
    /// Event info
    /// </param>

    var element = $get(this._OkControlID);
    if (element && !element.disabled) {
        if (this.hide() && this._OnOkScript) {
            window.setTimeout(this._OnOkScript, 0);
        }
        e.preventDefault();
        return false;
    }
},

如您所見,它調用e.preventDefault(); 這會導致OKControl的正常行為無法通過,而this.hide()將關閉模式彈出窗口本身。

如果您想了解更多信息,建議您從控制工具箱中閱讀ModalPopupBehavior .debug.js。

不要分配ok控件,這樣事件就可以正常工作。

也適用於取消控制,只是不分配它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM