ASP.NET 2.0 - Enter Key - Default Submit Button

One of the most annoying things in developing web pages is handling the "Enter key" for form submission. Enter key has been the favourite way users like to submit forms. Though we provide Buttons to click on, the easiest and intuitive way is that, I can enter some text, make some changes and then hit "Enter" to accomplish my submission.

"Enter" Key is handled in a little tricky way by uplevel browsers like Internet Explorer, when it comes to ASP.NET.

  • If there is a single Textbox and single button, then it becomes straight forward, the button is submitted. However, the event code doesnt get executed, though the page postsback.

  • If there are two or more, buttons, then it takes up the first button as the default button. However, it still doesnt execute the event handler but just refreshes the page.

You can supress the Enter key event using Javascript. But this would result in other undesirable effects like, any Enter key in the form i.e. within Text Area or basically where large text is entered, would be disabled.

The earlier work around was to associate a javascript function to each Button to verify the that the relevant button is submitted upon Enter key.

ASP.NET 2.0 introduces a wonderful work around for this. By simply specifying the "defaultbutton" property to the ID of the <asp:Button>, whose event you want to fire, your job is done.

The defaultbutton property can be specified at the Form level in the form tag as well as at panel level in the <asp:panel> definition tag. The form level setting is overridden when specified at the panel level, for those controls that are inside the panel.

Also, the Event Handler for the specified button, fires thereby simulating a true submit button functionality.

The following sample code contains a form and 4 panels with each of them containing different buttons. It can be noticed that for each panel, there is a default button specified which would trigger the corresponding button's event handler when "Enter" Key is pressed upon a text changed event.



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

<div>

<asp:TextBox ID="txt" runat="server"></asp:TextBox>

<asp:Button ID="Button5" runat="server" Text="Cancel" OnClick="Button5_Click" />

<asp:Button ID="btn1" runat="server" Text="Submit" OnClick="btn1_Click" />

<asp:Panel ID="pnl1" runat="server" defaultbutton="Button1">

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

<asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click" />

</asp:Panel>

<asp:Panel ID="Panel1" runat="server" defaultbutton="Button2">

<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>

<asp:Button ID="Button2" runat="server" Text="Button2" OnClick="Button2_Click" />

</asp:Panel>


<asp:Panel ID="Panel2" runat="server" defaultbutton="Button3">


<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>

<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>

<asp:Button ID="Button3" runat="server" Text="Button3" OnClick="Button3_Click" />

</asp:Panel>

<asp:Panel ID="Panel3" runat="server" defaultbutton="Button4">

<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>

<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>

<asp:Button ID="Button4" runat="server" Text="Button4" OnClick="Button4_Click" />

</asp:Panel>

</div>

</form>

The corresponding, sample events for the button clicks are


protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(Button1.Text);
}


protected void Button2_Click(object sender, EventArgs e)
{
Response.Write(Button2.Text);
}


protected void Button3_Click(object sender, EventArgs e)
{
Response.Write(Button3.Text);
}


protected void Button4_Click(object sender, EventArgs e)
{
Response.Write(Button4.Text);
}


protected void btn1_Click(object sender, EventArgs e)
{
Response.Write(btn1.Text);
}


protected void Button5_Click(object sender, EventArgs e)
{
Response.Write(Button5.Text);
}

Once we execute the above functionality, we can notice, the corresponding Buttons' text are displayed when the Enter key is pressed from within a panel and at the form level, it fires the btn1 Button's event.

This would be a very useful feature in scenarios where we have different sections of the page and would like to have Enter key fire corresponding submit button events.

Cheers and Happy Enter Keying !!!

Print | posted on Wednesday, April 12, 2006 1:22 PM

Comments on this post

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Nice one - thank you very much!
Left by Nick on Feb 26, 2007 1:57 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Works for me. Thanks for the info.
Left by Brian on Apr 02, 2007 6:17 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Not working in firefox.
Left by Sabarinth on Apr 26, 2007 5:23 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
great... :)
Left by Adeel on Aug 27, 2007 10:48 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
What to do when the input field and button are located within a user control?
Left by Jaco on Dec 17, 2007 2:10 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
It works in FireFox for me.
Left by Dukebaby on Feb 01, 2008 6:43 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
I second Jaco's question: What if the button is located within a user control?
Left by Ben on Feb 04, 2008 9:22 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
thank you very much
Left by rao on Mar 17, 2008 11:32 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks a lot... exactly what I was looking for! (And works fine in Firefox)
Left by Jagwio on Mar 25, 2008 7:30 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Just what we were looking for as well, for solving the issue in IE. Thanks! (And as other visitors noted, the issue didn't even need to be solved in Firefox! ;)
Left by Ben on Apr 25, 2008 1:23 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
And how to do it in Content page when using master pages?

I tried programmatically setting Form.DefaultButton = "btnOK" in Page_Load but that causes an error.
Left by Gary on May 13, 2008 2:40 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Use the UniqueID property of the button to set the Form.DefaultButton. Example: Form.DefaultButton = btnOK.UniqueID.
Left by chuck on May 14, 2008 12:05 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
great, it works!
Left by b2b on Sep 09, 2008 1:33 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...

dfhd




Left by fdhgd on Sep 13, 2008 10:16 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
this was a great help...

Thanks..
Left by Abhishek on Oct 04, 2008 2:36 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...


Left by <div> on Oct 06, 2008 2:03 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
when you go with tab to the cancel button and hit enter, instead of calling the Button5_Click (to display cancel)still executes the btn1_click (displaying submit)

any idea how to fix this?

Left by nicoleta on Oct 07, 2008 11:25 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Great! You saved us lot of time. Thank you!
Left by Ales on Oct 15, 2008 12:17 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
hggght
gfgfg


















Left by yty on Oct 20, 2008 2:14 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Very nice solution. g8888...keep it up...
Left by Umesh on Oct 24, 2008 1:41 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
You save me a whole day, dude. Thanks
Left by WotLK Power Leveling on Nov 02, 2008 10:45 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
My site and users thank you. Before I was splitting the form.
Left by LastEnd.com on Nov 10, 2008 8:19 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
this just saved my butt today. thanks man!
Left by Chris Williams on Nov 21, 2008 11:23 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thank you so much for the easy solution. It really helped me.
Left by Srikantha on Nov 26, 2008 2:53 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Excellent! Thanks!
Left by Lochner on Dec 02, 2008 12:33 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks you for giving a useful information.
Left by Jitendra Kumar on Dec 08, 2008 9:50 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Can this be possible with HTML submit control? I used HTML Control. How can i acheive the same..? Plz help me out
Left by Krishna on Jan 03, 2009 1:55 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Nice, thanks a lot!
Left by Makarand Yadav on Jan 07, 2009 2:39 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Nice article.. :) It helped me a lot.. Thanks
Left by Sai Krishna on Jan 09, 2009 12:52 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...

the solution is very nice but i work only first enter press
Left by arvind singh kushwaha on Jan 27, 2009 3:35 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
what is with DefaulButton & MultiLine & Firefox?
Left by Andreas Beraz on Jan 27, 2009 9:25 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
This was great, helped me run a fix on a site very easily.
Left by Rahul on Jan 27, 2009 10:39 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks, this saved me lots of time today!
Left by JimmyT on Mar 11, 2009 12:41 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
it will not work if master page and content page both having button and press enter in each text box.
Left by vira on Mar 17, 2009 2:44 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thank You for the solution.
Left by Huma on Mar 24, 2009 1:48 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
On the content page , you can wrap your control in a panel ,so you can specify the defaultButton for the panel.
Left by Ben on Apr 01, 2009 2:44 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thx alot 4 ur help
Left by Mahdy on Apr 29, 2009 3:15 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Hi, if there is a calendar control inside panel, and if that was modified and pressed enter - default button does not work :(
Left by Mashrur on Jul 01, 2009 3:07 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Good one
Left by Naveen on Jul 03, 2009 11:46 AM

# ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Dear Frnds,

I have to seen ur code, but i have similar to same problem , i my page 6 buttons and i am using asp buttons ans div tags..ok,
now we need when i enter key then submit want to fire and when ever i go by tab order that cooresponding button, then i put form load "defaultbutton="<buttonid>" " but its not working properly...


so plz help me any one
Left by Eeshwar on Jul 30, 2009 12:51 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
I think I was able to address the default button being inside a user control by doing the identical code for the code-behind/Page_Load of the user control itself. It seems to work but I'm not sure what would happen if you have more than one control set this value.
Left by celston on Jul 30, 2009 2:51 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks..Pls Keep it up..it saved my time and a day..gr8..
Left by Dinesh on Aug 15, 2009 1:11 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thank you for this SIMPLE solution. I was starting to use the __doPostback() and crazy JS blocks...yuck. So simple and clean. Thumbs UP UP!
Left by Jose on Aug 17, 2009 4:09 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
thanks for the solution..btw, anyone know a solution if i want the Nnter key to act like the Tab key? TIA!
Left by javaChip.AJAX on Sep 02, 2009 10:27 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
//search is button id
//added to protected void Page_Load

Page.ClientScript.RegisterHiddenField("__EVENTTARGET", search.UniqueID);
Left by chan on Sep 11, 2009 12:56 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks! I had my form in a table with the textbox and button inside a td so I had to put the asp:panel inside the td to get it to work.
Left by David on Oct 01, 2009 7:43 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
"uplevel browsers like Internet Explorer"

Isn't that a contradiction in terms?

:)
Left by Shane on Oct 04, 2009 10:23 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thank you for this very SIMPLE solution. I was starting to get confused
Left by classic video games on Oct 31, 2009 2:42 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Use the UniqueID property of the button to set the Form.DefaultButton. Example: Form.DefaultButton = btnOK.UniqueID.
Left by auto insurance on Nov 03, 2009 4:12 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
This solution will NOT work if a control in the form does not have focus. If you have a drop down list and select a value and hit enter, this will not fire the form to post back because the ddl does not have focus. So it's very easy to implement, but limited in ways.
Left by JSON on Nov 06, 2009 9:14 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks for sharing. I don't like the uniqueID.
Left by cleaner reviews on Nov 16, 2009 5:13 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks for this, I was previously using javascript, but when an autocomplete extendor was in play or a browser autocomplete showed the selected autocomplete value would not populate and work.

This solution did the trick. Thanks
Left by Scott on Nov 24, 2009 12:17 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Hehehe let me test, Giving results sooon
Left by jaluo on Dec 16, 2009 11:26 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
I know what you mean about the Enter key. You are absolutely right. Vera @ Secured Loans Canada
Left by Secured Loans Canada on Jan 05, 2010 3:11 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
try using a panel and setting the DefaultButton property to the button id:

<asp:Panel ID="Panel1" runat="server" DefaultButton="buttonSearch">
.
.
.
<asp:Button ID="buttonSearch" runat="server" Text="Search" />
</asp:Panel >

Left by The Mule on Jan 12, 2010 11:07 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks,

Indeed nice to guide small things.

But, does only the panel support DefaultButton property?
Or I can set default button in page setup for some table even?
Left by Dhruv M. Patel on Jan 20, 2010 10:19 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
"uplevel browsers like Internet Explorer" That is hilarious :)

This is my single most hated 'feature' of ASP.NET
Left by Mark on Jan 24, 2010 5:54 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Use the UniqueID property of the button to set the Form.DefaultButton.
Left by term life insurance on Jan 27, 2010 6:21 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
when you go with tab to the ADD button and hit enter, instead of calling the Button5_Click (to display ADD event)still executes the btn1_click (displaying submit) Plz give the solution for this.
Left by Neha Bhatia on Feb 23, 2010 11:46 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thank you for the help. I was facing the issue with button. I was using 4 button and was not aware of the new property Defaultbutton. Hope now it will works.
Left by Sole F80 on Mar 29, 2010 8:38 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
thanks for the read.. i've run into some of the same issues..
Left by Beats for Sale on Apr 10, 2010 6:03 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
I am glad to catch the idea from your article. It has information I have been searching for a long time. Thanks so much.
Left by bean bags chairs on Apr 17, 2010 11:44 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
yes this is a great shortcut. thanks for sharing this knowledge
Left by Buy Beats on Apr 18, 2010 2:30 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
I have this problem all the time. thanks for bringing it to life
Left by Hip Hop Beats on Apr 19, 2010 10:28 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Than you
Left by duckyvideos on Apr 25, 2010 8:59 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
great work man
Left by raj on Apr 26, 2010 11:22 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Wow, this just made my week. I was going crazy trying to figure out a solution. Score one for .NET and you for writing about this!
Left by David on Apr 27, 2010 4:03 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
very good guide especiallly for those who are noobs in.NET
Left by compact digital cameras on Apr 28, 2010 3:47 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Very helpful post. Thanks for putting up this informative article. Great layout.
Left by digital bathroom scale on May 02, 2010 10:30 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
This was an excellent article on ASP.NET. The info was very helpful to me.
Left by wireless outdoor speakers on May 02, 2010 6:48 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
You presented some great ideas in your article. Thanks for the post.
Left by samsonite luggage repair on May 03, 2010 7:25 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Very informative post. Thanks for sharing this article.
Left by bathroom wall cabinet on May 04, 2010 9:07 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
ASP.NET 2.0 this is good code for development
Left by samsung ln26c450 on May 08, 2010 1:30 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
This is a great article!
Left by zerona laser treatment on May 13, 2010 12:31 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Interesting post. Thanks for sharing this information.
Left by candle wall sconce on May 13, 2010 5:37 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Good post
And as other visitors noted, the issue didn't even need to be solved in Firefox! ;)Just what we were looking for as well, for solving the issue in IE. Thanks!
Left by Virtual Desktop For Windows 7 on May 17, 2010 2:21 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
I will try to get the hang of it! You really make it seem so easy with your presentation but I find this topic to be really something I think I would never understand. It seems too complicated and very broad for me. I am looking forward for your next post, Good post
Left by Guard Process on May 17, 2010 2:23 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
And as other visitors noted, the issue didn't even need to be solved in Firefox! ;)Just what we were looking for as well, for solving the issue in IE. Thanks for share!..........
Left by 进程保护 on May 17, 2010 2:25 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
There is code already generated available on the internet so you don't have to bother with this problem yourself.
Left by Violet on May 17, 2010 11:57 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
I think I'm going to bookmark this site since it had all the information I was looking for. Thanks so much to the owener. Look forward to seeing you again sometime.
Left by how to cure eczema on May 18, 2010 5:49 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Awesome solution.
Left by subbu + on May 19, 2010 7:21 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
is this tutorial still working on new firefox version?
Left by auto insurance in USA on May 22, 2010 2:59 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
hi, this is a fantastic post. i've just learned how to code and all i can say is it is really a headache. thanks for posting this mate.

cheers,

matt
Left by matt on May 23, 2010 8:41 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Yep this is what i wanted. It works great in firefox.
Left by Website optimalisatie on May 28, 2010 12:31 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Excellent post will take away a lot from this one.
Left by liquid meal on May 31, 2010 12:36 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
That helped. Thanks a lot.
Left by Aswin on Jun 04, 2010 8:31 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Seems to be a great solution for ASP users. Have to take that in mind for my next project. Haven't used ASP since I learn it at school.
Left by Summer Dresses on Jun 08, 2010 6:18 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks for the tips on ASP.NET
Left by Phen375 Review on Jun 08, 2010 8:50 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Very gooooooooooooood
Left by Mohammed on Jun 29, 2010 11:21 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Is there anyone else who can’t see the end part of this post? Maybe there is a javascript problem; but I did enjoy the part I could see...

Jeff
Left by Kindle 2 Skins on Jul 27, 2010 1:13 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Yep, I can see all the post; no problem.
Left by Canoe Paddles on Jul 29, 2010 7:17 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Hmmm... I think Jeff is right... I didn't see the end post either. Although I have been having issues with my computer...
Left by Creed Green Irish Tweed on Aug 03, 2010 5:56 PM

# Mr

Requesting Gravatar...
I saw the end of the post but not the beginning. What's going on?
Left by Skylights For Homes on Aug 09, 2010 7:02 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thank yoo much...
Left by Amol on Aug 12, 2010 9:07 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
It's a nice easy solution. It generates and requires javascript, so any user with JS turned off in the browser is SOL.
Left by Richard Howells on Aug 18, 2010 6:41 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
It's just fine, I understand your post. Thank you.
Left by generic viagra, viagra generic on Aug 24, 2010 10:39 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Your site has lots of information, thank you.
Left by pain pills, pain pills online on Aug 27, 2010 3:52 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Very Good. This is just what I need.

and the following comment said can use panel instead of the form, so we can setup the multiple default buttons.

Thank you very much.

Left by Henry on Sep 01, 2010 3:06 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Pity them. They are looking for the opportunities & try to get the new job. Understand that it was illegal, but they have a right to live, Can we said that the wall kill them? May be both countries should take the right action.
Left by best baby gifts on Sep 03, 2010 11:55 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
This is one heck of a share. Really helpful to someone like myself who is getting started in coding.
Left by wireless laser printers on Sep 05, 2010 1:36 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
lots of information here, thank you.
Left by Gadget Tips on Oct 17, 2010 8:39 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Works in Firefox too!
Left by Home cholesterol test guy on Nov 25, 2010 11:25 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Great share!! i hope to see more method like this
Left by malaysia web design on Dec 22, 2010 7:24 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks for the code - it should come in handy.
Left by Sun Dresses for Women on Jan 19, 2011 7:50 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
What If the button is located within a USER CONTROL?
Left by Subramanian on Jan 27, 2011 10:16 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Brilliant tip.
Left by Melbourne Town on Feb 16, 2011 8:27 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader.
Left by Stephanie Fox on Mar 11, 2011 10:56 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Perfect, thanks for help.
Left by ozgur on Mar 15, 2011 5:47 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Indeed. That is also my problem. Well, thank you for sharing some tips on how to make it easy. I will try what you said here.
Left by wart removal on Mar 27, 2011 10:10 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Nice! Very easy and straightforward.

as compare to JAVA
Left by Qaisar on Sep 04, 2011 11:51 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Wow, this just made my week. I was going crazy trying to figure out a solution. Score one for .NET and you for writing about this!
Left by oldschool on Sep 07, 2011 3:08 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Many thanks for the code - I've tried it out on my wesbsite, works a treat.
Left by Finance Director on Oct 07, 2011 7:48 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Great simple solution! Thanks. Works in IE and Firefox
Left by Bill on Oct 17, 2011 11:53 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
This solution will NOT work if a control in the form does not have focus. If you have a drop down list and select a value and hit enter, this will not fire the form to post back because the ddl does not have focus. So it's very easy to implement, but limited in ways.
Left by Jual Lukisan on Dec 26, 2011 2:30 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
cool worked perfect
Left by Murthy on Feb 28, 2012 9:25 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Tnks a lot !
Left by Esteban on May 04, 2012 10:57 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Works like a charm for me, thanks for the tip ...
Left by Grossiste Toys on May 26, 2012 3:54 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
This is an awesome code. I absolutely love it. People are lazy, and they'd much rather have they option of pressing enter in a Form. So thanks for the help with that.
Left by Mo on Jun 04, 2012 3:10 AM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Greate, work for every web browser
Left by Lai on Jun 11, 2012 2:53 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Thanks very much - tried on my web site work perfectly. Much better than java for the non programmers amongst us. All the best Martyn!!!!
Left by Sellmylaptop on Feb 20, 2013 11:38 PM

# re: ASP.NET 2.0 - Enter Key - Default Submit Button

Requesting Gravatar...
Working perfectly in Chrome but havent tried it in firefox. Doing it now
Left by home skylights on May 30, 2013 3:04 PM

Your comment:

 (will show your gravatar)