In ASP. NET, let different text boxes on the same page press enter to respond to different events

Source: Internet
Author: User

InASP. NETIf multiple text boxes exist on the same page, press "enter" in each text box to return the first one by default.ButtonOfClickEvents, how can I press the Enter key without causing unexpected responses, or how to press the Enter key in different places to get different responses,This problem has plagued me for a long time and has not yet been completely solved. I will share my current discussions with you for a better understanding.
1. No response is triggered when you press the Enter key anywhere on the page.
If you do not need to set carriage return for submission on the entire page, you can convert the carriage return function of the entire pageTabTo add the following content to the file header:Code:

<Script language = "JavaScript" event = "onkeydown" for = "document">

If (event. keycode = 13)

Event. keycode = 9;

</SCRIPT>

 

2. Press enter in different places to get different responses
If the same page has multiple text boxes (Textbox), Each text box corresponds to a different submit button (Button)For example, on the following "login" page, there are two text boxes: "Enter mailbox number" and "enter account number" and"Enter email" and "EnterCommunity.



Expected results:
1. Enter the mailbox number and press enter to respond to the event of the "Enter mailbox" button. For simplicity, the "Enter mailbox" button will display the "Mailbox: * *** "(The *** is the entered mailbox number), as shown in:

2. Enter the account and press enter to respond to the event of the "Enter community" button. For simplicity, the "Enter community" button will display the "Community" in the "information display" text box: * *** "(The *** is the entered community account), as shown in:

The implementation steps are as follows:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.