how to make a "Default" button on web page

I have a web dialogue with a couple of text fields and a couple of buttons. I want the user to type data into the fields. When user hits Enter key, I want the “Default” button to fire.

I know I can do this programmatically (by checking KeyPressed events), but in Desktop Apps a button can be assigned as the Default and behaves correctly with no need of programming. The default button usually displays a focus ring, or a colour tint to indicate it is ready to receive the Enter key action.

Is there a web button equivalent? Or do I need to create coding to simulate this effect?

You’ll need to code it.

Hm. Doesn’t that take a lot of back and forth cycles to the server? I’m right in the middle of this now also.

Yes, it’s not a pretty workaround - but the overall effect seems to work fine.
This is what I did:- I created a Method (called “Login”) to contain the action code of my default button (called “cmdLogin”). So the button’s action event code is simply: Login()

I then put the following code in a text control’s KeyPressed Event:-

Select Case details.KeyCode Case details.KeyEnter cmdLogin.SetFocus Login() End Select

So, the KeyPressed event checks if the Enter key was pressed. If it was, then it sets focus on my default button (Completely pointless, but just for visual effect!), and the code then actions the Method “Login()” which is the same method that would have been called had the button really been clicked. It works …

Here is a Log-in form solution. 3 controls, of which 2 WebTextFields (prefix txt) , and one WebButton (prefix cmd)
[code]Dim S() AS String
Dim PassID As String
Dim UserID As String
Dim BtnID As String

PassID = Me.txtPassword.ControlID
BtnID = Me.cmdLogin.ControlID
UserID = Me.txtUserName.ControlID

S.Append "var Pass = document.getElementById('" + PassID + "');"
S.Append "var User = document.getElementById('" + UserID + "');"

S.Append "var Btn = document.getElementById('" + BtnID + "_inner');"

S.Append "Pass.addEventListener('keyup', function (e) { if (e.keyCode==13) { Btn.click(); }; }, false); "
S.Append "User.addEventListener('keyup', function (e) { if (e.keyCode==13) { Btn.click(); }; }, false); "

ExecuteJavaScript (Join(S, " "))[/code]

Each of the text fields listen for “Enter/Return” and when got it it tells default button it has been clicked.