Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set a default 'enter' on a certain button

There is a textbox on a ContentPage. When the user presses Enter in that textbox I am trying to fire a 'Submit' button on this ContentPage. I'd like to fire off that particular button's event.

Instead, there is a search textbox & button on the top of the page from a MasterPage, and this search button's event fires off.

How do I control to fire off this ContentPage's submit button, instead of the MasterPage's search button?

I am using Ektron CMS for my content management.

like image 709
Ron Avatar asked Oct 03 '11 16:10

Ron


People also ask

How to set Enter key on a button in ASP net c#?

You can use a keypress event for each textbox which will do different things.. so: private void a_keyPress(object sender, KeyPressEventArgs e) { RadTextBox myBox = (RadTextBox)sender; if (e. KeyChar == (char)Keys. Return) { if (myBox.ID == "textbox1") // then do stuff... } else if //do stuff... }

How to make default button in vb net?

Also, in the form's property sheet you can find, under Misc, the property 'AcceptButton'. This will give you a list of buttons on the form - just select the one you want. The button selected as the AcceptButton will behave as the 'default' button.

What is the default button?

In a GUI (graphical user interface), such as in Microsoft Windows, the default button is the button chosen if you press Enter on the keyboard. This button represents the option you are most likely to choose, or which is safest to choose if you press Enter accidentally.


1 Answers

The easiest way is to put the fields and button inside of a Panel and set the default button to the button you want to be activated on enter.

<asp:Panel ID="p" runat="server" DefaultButton="myButton">   <%-- Text boxes here --%>   <asp:Button ID="myButton" runat="server" /> </asp:Panel> 
like image 158
Kirk Avatar answered Sep 23 '22 20:09

Kirk