Answers
Dec 20, 2006 - 11:54 PM
I mean I want to "simulate" a button click and there might be several buttons on the page doing different stuff.
Dec 21, 2006 - 05:27 AM
Sometimes, this is the default behavior when the enter key is pressed...it depends on whether or not you a single "submit" button on a page (this includes usercontrols, third party controls, etc.).
I think there are a couple of ways you could go about simulating this behavior - both of them being client-side, however.
1) Wire up a global javascript event that "traps" the keypress event for the enter key, or
2) Add a javascript function which will conditionally process the events regardless of which control initiated the submit, ie:
!
Granted, it's not a server-side solution, but really, none of the events are truly server-side...they're just client-side events that initiate specific server-side routines based on the information contained in the __doPostBack javascript function.
Dec 27, 2006 - 08:54 PM
Try this
This will set btnSubmit as default button of the form
Dec 28, 2006 - 02:29 AM
I ended up doing it this way serverside (ASP.NET 2 / C#):
string loginFocusScript = "!";
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "loginFocus", loginFocusScript);
Not too happy with it, but it works.
Add New Comment