hi
i m using asp .net calendar control everything works fine
currently using button for show and hide
but dont know how to code for closing it on esc key press
Printable View
hi
i m using asp .net calendar control everything works fine
currently using button for show and hide
but dont know how to code for closing it on esc key press
You can use javascript to capture the escape keypress event.
Code:var keypress = (window.event) ? event.keyCode : e.keyCode;
if(keypress == 27)
{
self.close();
}
hey mendhak
i got this error "Microsoft JScript runtime error: 'e' is undefined"
pls help
The window.event check is supposed to see if it's IE or firefox and if you're using IE, it should have used event.keyCode, not e.keyCode.
Can you do an alert(window.event) to see if it's null for you or not?
hey mendhak
thanks for ur kind support
i hv found a way to solve this prob with the help of ur code
hope this may be helpful for others
Code:<script type="text/javascript" language="javascript">
function EscPressed(evn)
{
var keynum;
if(window.event) // IE
{
keynum = window.event.keyCode;
}
else if(evn.which) // Firefox
{
keynum = evn.which;
}
if(keynum==27)
{
var oCal=document.getElementById('<%=Session["CalClientId"]%>');
if(oCal)
{
oCal.style.display ='none';
}
}
}
document.onkeyup = EscPressed;
</script>
Ah, nice and expansive. No prob.