关闭转义键ajax ModalPopupExtender无法正常工作

时间:2014-03-18 02:31:18

标签: asp.net ajax modalpopupextender

我使用以下代码关闭modalPopup但由于某种原因无效。

<script>
     function pageLoad(sender, args){
      if(!args.get_isPartialLoad()){
        //  add our handler to the document's
        //  keydown event
         $addHandler(document, "keydown", onKeyDown);
       }
  }

function onKeyDown(e){
if(e && e.keyCode == Sys.UI.Key.esc){
    // if the key pressed is the escape key, dismiss the dialog
    $find('ModalPopupExtenderPanelFullViewProductos').hide();
     }
   } 
 </script>

<ajax:ModalPopupExtender ID="ModalPopupExtenderPanelFullViewProductos"
                         runat="server" TargetControlID="LinkButtonDummy"  
                         BackgroundCssClass="modalBackground" 
                         PopupControlID="PanelFullViewProductos"
                         X="20" Y="50" DropShadow="true" 
                         RepositionMode="None">
 </ajax:ModalPopupExtender>

1 个答案:

答案 0 :(得分:1)

您必须为模态弹出扩展器设置一个BehaviorID。然后您可以使用

$find('BehaviorID').hide();

如果它满足你,请标记为答案..