加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

ASP.NET ModalPopupExtender单击“事件”

发布时间:2020-12-16 03:36:24 所属栏目:asp.Net 来源:网络整理
导读:我有一个使用ASP.NET AJAX的ASP.NET应用程序.我正在使用ASP.NET AJAX Toolkit向用户显示一个对话框.当用户在对话框中单击“是”时,我想在后面的代码中处理该事件.但是,我注意到我的点击事件没有到达.这是主要代码: asp:Panel ID="dialogContinuePanel" runa
我有一个使用ASP.NET AJAX的ASP.NET应用程序.我正在使用ASP.NET AJAX Toolkit向用户显示一个对话框.当用户在对话框中单击“是”时,我想在后面的代码中处理该事件.但是,我注意到我的点击事件没有到达.这是主要代码:

<asp:Panel ID="dialogContinuePanel" runat="server" style="display:none;" DefaultButton="yesButton">    
  <div>Are you sure you want to continue?</div>
  <div>
    <asp:ImageButton ID="yesButton" runat="server" AlternateText="Yes" ImageUrl="/resources/yes.png" OnClick="yesButton_Click" />
    <asp:ImageButton ID="noButton" runat="server" AlternateText="No" ImageUrl="/resources/no.png" />
  </div>
</asp:Panel>

<asp:LinkButton ID="hiddenLinkButton" runat="server" Text="" />
<cc1:ModalPopupExtender ID="dialogErrorExtender" runat="server" OkControlID="yesButton" 
  TargetControlID="hiddenLinkButton" PopupControlID="dialogContinuePanel"   
  CancelControlID="noButton" />

我的守则背后:

protected void yesButton_Click(object sender,EventArgs e)
{
  string argument = yesButton.CommandArgument;
  // Do some processing and redirect the user
}

如何处理与ModalPopupExtender一起使用的Button的click事件?我究竟做错了什么?

解决方法

您需要从模态弹出扩展程序定义中删除OkButton属性.我知道这似乎是违反直觉的,但是当你添加这个引用时,它实际上会挂起来在客户端工作而不会导致回发.

所以试试这个:

<cc1:ModalPopupExtender ID="dialogErrorExtender" runat="server" 
  TargetControlID="hiddenLinkButton" PopupControlID="dialogContinuePanel"   
  CancelControlID="noButton" />

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读