如何在按下esc键时在一个页面中使用两次的usercontrol中关闭modalpopupextender? [英] How to close modalpopupextender in usercontrol that is used twice in one page when esc key is pressed?

查看:79
本文介绍了如何在按下esc键时在一个页面中使用两次的usercontrol中关闭modalpopupextender?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript">

    function pageLoad(sender, args) {
        if (!args.get_isPartialLoad()) {
            $addHandler(document, "keydown", onKeyDown);
        }
    }

    function Hide(controlID) {
        var mpe = $find(controlID);
        mpe.hide();
        var mpe = $find('ModalPopupExtender1');
        mpe.hide();
    }
    function onKeyDown(e) {
        if (e && e.keyCode == Sys.UI.Key.esc) {
            Hide(document.getElementById("<% =ModalPopupExtender1.ClientID%>"));
        }
    }
</script>Close with escape key ajax ModalPopupExtender not working

in two days of searching I can't still find any answer for this.

Anyway, I have modal pop up extender in usercontrol then I used my user control twice in one page.

My problem is I can't close it with esc key is click with the code above. it always null or cant find something.

Then, I tried using behaviorID but it cannot be done too.

    function pageLoad(sender, args) {
        if (!args.get_isPartialLoad()) {
            $addHandler(document, "keydown", onKeyDown);
        }
    }


    function onKeyDown(e) {
        if (e && e.keyCode == Sys.UI.Key.esc) {
            $find('bhiModalPopupExtender1').hide();
        }
    }


<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1" TargetControlID="hdnModalPopup" BehaviorID="bhiModalPopupExtender1"

    CancelControlID="hdnModalPopup" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>Thanks for helping.

推荐答案

addHandler(document,keydown,onKeyDown );
}
}

函数隐藏(controlID){
var mpe =
addHandler(document, "keydown", onKeyDown); } } function Hide(controlID) { var mpe =


find(controlID);
mpe.hide();
var mpe =
find(controlID); mpe.hide(); var mpe =


find('ModalPopupExtender1');
mpe.hide();
}
函数onKeyDown(e){
if(e&& e.keyCode == Sys.UI.Key.esc){
Hide(document.getElementById( <% = ModalPopupExtender1.ClientID %> ));
}
}
< / script > 使用转义密钥关闭ajax ModalPopupExtender在两天的搜索中无法工作

我仍​​然无法找到任何答案。

无论如何,我在usercontrol中有模态弹出扩展器,然后我在一个页面中使用了我的用户控件两次。

我的问题是我无法用esc键关闭它,点击上面的代码。它总是无效或无法找到某些东西。

然后,我尝试使用behaviorID,但它也无法完成。

function pageLoad(sender,args){
if(!args.get_isPartialLoad()){
find('ModalPopupExtender1'); mpe.hide(); } function onKeyDown(e) { if (e && e.keyCode == Sys.UI.Key.esc) { Hide(document.getElementById("<% =ModalPopupExtender1.ClientID%>")); } } </script>Close with escape key ajax ModalPopupExtender not working in two days of searching I can't still find any answer for this. Anyway, I have modal pop up extender in usercontrol then I used my user control twice in one page. My problem is I can't close it with esc key is click with the code above. it always null or cant find something. Then, I tried using behaviorID but it cannot be done too. function pageLoad(sender, args) { if (!args.get_isPartialLoad()) {


这篇关于如何在按下esc键时在一个页面中使用两次的usercontrol中关闭modalpopupextender?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆