|
-
Mar 4th, 2009, 07:17 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] help in closing calendar on Esc Key
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
* If my post helped you, please Rate it
* If your problem is solved please also mark the thread resolved it is there in right top of page under thread tools
* Why Rating is useful
-
Mar 4th, 2009, 12:40 PM
#2
Re: help in closing calendar on Esc Key
You can use javascript to capture the escape keypress event.
Code:
var keypress = (window.event) ? event.keyCode : e.keyCode;
if(keypress == 27)
{
self.close();
}
-
Mar 5th, 2009, 12:13 AM
#3
Thread Starter
Hyperactive Member
Re: help in closing calendar on Esc Key
hey mendhak
i got this error "Microsoft JScript runtime error: 'e' is undefined"
pls help
* If my post helped you, please Rate it
* If your problem is solved please also mark the thread resolved it is there in right top of page under thread tools
* Why Rating is useful
-
Mar 5th, 2009, 03:32 AM
#4
Re: help in closing calendar on Esc Key
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?
-
Mar 5th, 2009, 05:16 AM
#5
Thread Starter
Hyperactive Member
Re: help in closing calendar on Esc Key
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>
* If my post helped you, please Rate it
* If your problem is solved please also mark the thread resolved it is there in right top of page under thread tools
* Why Rating is useful
-
Mar 5th, 2009, 05:50 AM
#6
Re: [RESOLVED] help in closing calendar on Esc Key
Ah, nice and expansive. No prob.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|