Using Enter key for login page makes it beep?

Codeless

Regular
Joined
Jan 24, 2003
Messages
59
Location
Great NW
I have this script on my login page where there are two textboxes that collect username and password:

Code:
<SCRIPT LANGUAGE="javascript">
if (document.all)
{ 
      document.onkeydown = function ()
      {			
          var key_enter= 13; 
          if (key_enter==event.keyCode)
          {
               document.getElementById('LinkButton1').click()
          }
      }
}
</SCRIPT>

I also have an event that handles the linkbutton1.click event in the code behind. I've got two questions...Why is it beeping when I press enter? And the second is the password dissapears when I tab over to linkbutton1. Anyone know why?
 
I don't know C#, and I don't know ASP.Net, but in VB.Net for Windows Forms, this is what you have to do to remove the beep:
Visual Basic:
Public Sub TextBox_Keypress(ByVal sender As Object, ByVal e As System.KeyPressEventArgs) 'or w/e it should be

If convert.tochar(keys.enter) = e.keychar then
    'do whatever here
    e.Handled = True 'removes the beep
End If

End Sub
 
Back
Top