disable enter key

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

Hi,

How do I disable the enter key for a "Form"? so that user has to click the
"Submit" button.
Is there a way of doing it other than using Java/VB script?

Thanks,
Stephen
 
I'm not sure about web forms but this is how you would do it for windows
forms..
override the ProcessCmdKey function of the form as below:

Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, ByVal keyData As _
System.Windows.Forms.Keys) As Boolean
Select Case CType(msg.WParam.ToInt32, Keys)
Case Keys.Enter
'indicates you've handled the message sent by the enter key
press here; basically, you're eating up these messages
Return True
Case Else
Return MyBase.ProcessCmdKey(msg, keyData)
End Select
End Function

I assume you need this functionality for web forms. As I said, I'm not
familiar with that area - Sorry :(
Maybe this would help a bit though...

Imran.
 
Back
Top