How to fire submit button on enter key press on page in asp.net ?


Hi

while working on asp.net project, so many time we will get a requirement to submit data on “Enter Key” press.

We can do this task like this
1.If we have to make “Enter Key” as default save button then we can do like this in .aspx page

<form id="form1" defaultbutton="BtnSubmit" runat="server">

//html code

</form>

2. If we have two or more section of registration form and if the user is on that section and if we have make there “Enter Key” as default save button then we can do like this in panel

<asp:Panel ID="Panel1" DefaultButton="Button1" runat="server">

//html code

</Panel>

Advertisement

2 thoughts on “How to fire submit button on enter key press on page in asp.net ?

  1. aamir November 2, 2012 / 11:16 am

    It’s a really very informative information. It’s very useful and knowledgeable for me. i was stuck while coding this. I will bookmark this page for coding help.

    • Chandra Dev November 2, 2012 / 11:36 am

      Nice to know that you liked this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.