Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] ASP.NET - Multiple Buttons for Submit

Started by Phytoplankton May 26, 2009 at 4:29 PM 1 replies 2k views
Original Post
Phytoplankton
Phytoplankton
I've working with ASP.NET, and I've got two separate buttons that I want to submit when the user hits Enter. ........[search text] [Search] ... ... ...UserName: blahblahblah ...Password: blahblahblahblah ...Confirm PW: blahblahblahblah ...Email: SomeEmail@somedomain.com ...[OK] If the user last gave the focus to the search text box, I want enter to click the Search button. If they last gave the focus to something in the new user section, I want enter to click the OK buton. How do I accomplish this?
-----OpenEndedAdventure.com - The Adventure that Anyone Can Edit.
Codeka
Codeka
You can use &#106avascript to simulate clicking on the correct button when they press enter in one of your controls. I like using <a href="http://jquery.com/">jQuery</a> for this kind of stuff, but there's plenty of options...
Optus
Optus
Look at the Panel control. () It has an attribute "DefaultButton" that you can set to the ID of a button. When the users presses the enter key within that panel the corresponding button is automatically "clicked".

i.e.

<asp:Panel ID="SearchPanel" DefaultButton="SearchButton" runat="server"><asp:TextBox ID="SearchTextBox" runat="server"/><asp:Button ID="SearchButton" runat="server"/></asp:Panel><asp:Panel ID="DetailsPanel" DefaultButton="OKButton" runat="server">...UserName: blahblahblah...Password: blahblahblahblah...Confirm PW: blahblahblahblah<asp:Button ID="OKButton" runat="server"></asp:Panel>


This is just off the top of my head and may have syntax errors but you get the idea.

Also: Panel control at MSDN

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.