Accumulate [C #]-C # Replace the tab key with the Enter key on the keyboard

Source: Internet
Author: User

Note: When entering table data, after entering a text box, you need to use the tab key to switch when entering the next text box. However, some users prefer to use the Enter key to switch to the next one, this method replaces the tab key with enter.

Effect:

Note: The enter key number on the keyboard is 13.

The number of the tab key on the keyboard is 9.

FunctionCode:

 1   Private   Void  Setent ()  2   {  3               Foreach (Control txt In ( This . Page. Form. findcontrol ( " Contentplaceholderentity  "  ). Controls)  4   {  5                   If (Txt Is  System. Web. UI. webcontrols. textbox)  6   {  7                       If (Textbox) txt). cssclass! = "  Erp_textarea "  )  8 (Textbox) txt). Attributes. Add ( "  Onkeydown  " , "  If (window. event. keycode = 13) window. event. keycode = 9  "  );  9   }  10                   If (Txt Is System. Web. UI. webcontrols. dropdownlist)  11   {  12 (Dropdownlist) txt). Attributes. Add ( "  Onkeydown  " , "  If (window. event. keycode = 13) window. event. keycode = 9  "  );  13   }  14                  If (Txt Is  System. Web. UI. webcontrols. checkbox)  15   {  16 (Checkbox) txt). Attributes. Add ( "  Onkeydown  " , "  If (window. event. keycode = 13) window. event. keycode = 9  "  );  17  }  18   }  19 }

 

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.