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.
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... }
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With