I had shown a Panel Pop up windows using Ajax and what i have to do is i want to close the window when user press the Esc key.
IS this is possible? Please help me if any one know about this or previously done this.
Thanks
I had shown a Panel Pop up windows using Ajax and what i have to do is i want to close the window when user press the Esc key.
IS this is possible? Please help me if any one know about this or previously done this.
Thanks
Add the script in your page to close the modal pop up with the ESC key
<script type="text/javascript">
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('mdlPopupExtender').hide();
}
}
</script>
Suppose we have two ModalPopupExtender Control, First of all set BehaviorID of each modal control to can access it from java script, I name the first control P2 and second P3. Write below code in through head tag:
<script type="text/javascript">
document.onkeyup =Esc;
function Esc()
{
var KeyID =event.keyCode;
if(KeyID==27)
{
if($find("p2"))
{
$find("p2").hide();
}
if($find("p3"))
$find("p3").hide();
}
}
</script>
we use $find(p2) to be sure the modal popup is existed in the page.
Here is the link through which you can easily close the window from eascape button press:
http://www.codeproject.com/KB/scripting/Javascript_for_modalpopup.aspx
hope this help.