Home  >  Article  >  Backend Development  >  Asp.net default enter button settings

Asp.net default enter button settings

巴扎黑
巴扎黑Original
2016-12-20 15:53:441439browse

Actually, I have been exposed to how to set the default enter button on the asp.net page early on, but I didn't record it at the time. I encountered it again today. I couldn't find it after searching through the information, and I couldn't solve it according to the methods on the Internet. It was so painful.

I believe everyone knows the online method. It’s nothing more than setting the following js code on the aspx page:

                                                                                                                                                                                               if (event.keyCode == 13) {
                                                                                                                                                                                               But this code for me, if the button is an ImageButton , this code can be used; if the button is a Button, this code will not work. I tried it for a long time without success, and I was very puzzled. Later, I took a look online and saw a question about button id. Then I was thinking, is there something wrong with the button ID? The id must have changed after being compiled.

                                                                                                            Finally, I used the browser to browse the page where the default enter button needs to be set, checked the source code, found the id of the button, copied it, it is a long section, similar to ctl00_ContentPlaceHolder1_Button1, replaced this with the button id in the js code, and ran Page, press Enter, it’s normal.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn