Results 1 to 6 of 6

Thread: [RESOLVED] help in closing calendar on Esc Key

  1. #1

    Thread Starter
    Hyperactive Member su ki's Avatar
    Join Date
    Oct 2007
    Posts
    354

    Resolved [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

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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();
    }

  3. #3

    Thread Starter
    Hyperactive Member su ki's Avatar
    Join Date
    Oct 2007
    Posts
    354

    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

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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?

  5. #5

    Thread Starter
    Hyperactive Member su ki's Avatar
    Join Date
    Oct 2007
    Posts
    354

    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

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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
  •  



Click Here to Expand Forum to Full Width