首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ModalPopupExtender不回发

ModalPopupExtender不回发
EN

Stack Overflow用户
提问于 2010-07-06 18:49:27
回答 2查看 5.4K关注 0票数 0

我有一个页面,其中我有一个ModalPopupExtender。现在,显示为ModalPopup的面板有两个按钮,即"Invite“和"Cancel”。我的问题是,当我单击这两个按钮中的任何一个时,都不会发生回发,并且我无法运行我的服务器端代码。

当我点击“邀请”按钮时,它只是隐藏了ModalPopupExtender控件,什么也不做!

代码语言:javascript
复制
    <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>

请帮帮忙。

谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-07-06 18:55:04

去掉这部分标记:

代码语言:javascript
复制
OkControlID="btnInvite" CancelControlID="btnCancel"

评论后更新:

在客户端的初始化阶段,执行这段代码:

代码语言:javascript
复制
    if (this._OkControlID) {
        this._okHandler = Function.createDelegate(this, this._onOk);
        $addHandler($get(this._OkControlID), 'click', this._okHandler);
    }

因此,基本上它为_onOK函数创建了一个处理程序:

代码语言:javascript
复制
_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。

票数 0
EN

Stack Overflow用户

发布于 2011-03-01 21:49:04

不要指定ok控件,这样事件就可以正常工作了。

此外,它也适用于取消控制,只是不要分配它们。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3185540

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档