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 }