The setting of the ASP. NET default return button

Source: Internet
Author: User
In fact, a long time ago in the Web page on how to set the default carriage return button, but it was not recorded. Again today, the information can not be found, in accordance with the online approach also can not solve, it called a pain.

The online approach is believed to be known to all. It's all about setting the following JS code on the ASPX page:

<script language= "javascript" type= "Text/javascript" >
function Document.onkeydown ()
{
var e = event.srcelement;
if (Event.keycode = = 13) {
document.getElementById ("button ID"). click ();
}
}
</script>

But this code for me, if the button is ImageButton, this code can be used, if the button is the key, the code is invalid. Did not succeed for a long time, Gray often wonder. Later on the internet to look at, see the issue of button ID. And then wondering, is there a problem with the ID of the button? The ID that was compiled must have changed.

Finally, I use the browser to browse the page that needs to set the default carriage return button, view the source code, find the button ID, copy it down, that is a long paragraph, like Ctl00_contentplaceholder1_button1, replace this with the JS code inside the button ID, Run the page, enter, normal.
  • 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.