Multiple forms on aspx and ENTER key

G

Guest

I received a design change to add an additional search textbox to our header
control for completely different type of search than one on the left side of
the page. Each search textbox is submitted by different linkbuttons to allow
me to handle each click event on the postback.

My problem is handling what happens when a user presses ENTER. I could trap
the Keypress event to check that they've entered text by checking which
textbox has focus and if they did, call the click() event, but I don't see a
way to determine focus in javascript. Any suggestions would be appreciated in
handling these multiple forms.

Thanks.
 
S

S. Justin Gengo

Dave,

I have a javacript object that is free and comes with all source code. It
has a few handy javascripts in it. One of them lets you specify which button
is clicked when you press enter while in a text box.

You may find a demo of all the scripts the component has and a download for
the component here: http://www.aboutfortunate.com?page=javascriptdemo

If you have any questions about the component feel free to email me.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Joined
Jun 29, 2006
Messages
2
Reaction score
0
If you are using .NET2, then the easy way to do this is to surround each of the different forms with an asp: panel. In .NET2, the panel control has a DefaultButton property. For each form, set the DefaultButton property to the correct button for that form. This avoids problems in javascript like cross-browser issues (the above code worked in IE but not firefox for me), and the fact that the button id is different in .NET when it gets to the browser.

<asp: Panel ID="Panel1" runat="server" DefaultButton="btnSignup">
... signup form elements including a button named "btnSignup" ...

</asp: Panel>

etc for each form.

Hope this helps,

Dave

David Conlisk
Freelance Programmer
 
Joined
Jun 29, 2006
Messages
2
Reaction score
0
Actually, on further investigation this appears to be quite buggy - anyone else had any experience with it? Or have a simple, reliable solution?

Cheers,

Dave

David Conlisk
Freelance Programmer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,786
Messages
2,569,626
Members
45,328
Latest member
66Teonna9

Latest Threads

Top