Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 233661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:07:16+00:00 2026-05-11T20:07:16+00:00

I am writing an asp.net application and have a form where a user must

  • 0

I am writing an asp.net application and have a form where a user must press a key to have a textbox become visible so that he/she can login. When the key is pressed, I want a label to disappear and a textbox to become visible. For some reason the ‘onkeydown’ event is not firing in FF or IE, but it works fine in Chrome. The application will be run on an AML terminal using the Links browser, but I am not able to test on that platform right now. Here is my code:

<form id="form1" runat="server" onkeydown="CheckKey(event.keyCode)" 
enableviewstate="True" submitdisabledcontrols="False" visible="True">

<script type="text/javascript">

    function SetVisibility() {
        var txtbx = document.getElementById("txtbx_login")
        txtbx.style.display = "none";
        var form = document.getElementById("form1")
    }

    function CheckKey(keycode) {
        if (keycode == 113) {
            var txtbx = document.getElementById("txtbx_login")
            txtbx.style.display = "";
            var lbl = document.getElementById("lbl_login")
            lbl.style.display = "none";
        }
    }

</script>

******other form elements******

</form>

The only way have been able to get the onkeydown event to work is if the textbox control is showing and has focus. Am I missing something? Thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:07:16+00:00Added an answer on May 11, 2026 at 8:07 pm

    I think the problem is that the onkeydown check is made on the form.

    Try moving it to the body element, or better, use javascript to add the event handler to a window event:

    function handleKeypress(e){
    
           var keycode = e.keyCode || e.charCode;
    
           if (keycode == 113) {
                var txtbx = document.getElementById("txtbx_login")
                txtbx.style.display = "";
                var lbl = document.getElementById("lbl_login")
                lbl.style.display = "none";
            }
    
        }
        window.onkeypress = handleKeypress;
    

    In firefox you’ll need to use event.charCode as well. I haven’t tested the above in all browsers but it’s a start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an ASP.NET MVC application and I have a form where a user
I am writing a web application on Asp.Net MVC 3. Assume that we have
for reason I won't bore you with, I'm writing an asp.net application that must
In the ASP.Net application I am writing I need to be able to have
In a asp.net/c# web application I am writing a jQuery script. I have an
I have been writing an application using ASP.Net MVC4, where the majority of the
I'm writing an ASP.net application that uses Windows Identity Foundation. My ASP.net application uses
We have an old asp.net application that has no unit tests, integration tests, component
I'm writing my first asp.net mvc application and I have a question about custom
I am writing a basic blogging application in ASP.NET MVC. I have a Post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.