.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

how to set the default enter key to submit form

Posted By: Ramesh     Posted Date: October 05, 2009    Points:2   Category :ASP.Net
Hi Friends,

how to set the default enter key to submit form? I have a Form and if user filled the form and hit enter button than it should save the data.

I need to set the default save button when user hit enter button

I am using C# and ASP.NET


Author: Lakhan Pal Garg             
Posted Date: October 06, 2009     Points: 5   

Hi Ramesh-
use the Following Code:

Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit");

In the above Code btnSubmit is the id of button on click of which you want to submit page.

Thanks & Regards
Lakhan Pal Garg

Author: Virendra Dugar             
Posted Date: October 07, 2009     Points: 5   

Hi Ramesh,

Other possible and easy solution is Place the whole page in <asp:Panel></asp:Panel> tag. ASP.NET 2.0 comes with a new property "Default Button". Just set the DefaultButton property of Panel Control to your button's ID.

I assume you are working with ASP.NET 2.0 or Higher version. This will not work with 1.1.


Author: Nabin             
Posted Date: February 03, 2010     Points: 5   

hi Virendra

is the code like this or nething wrong in it??

<asp:Panel ID="pan" runat="server" DefaultButton="btnsubmit"><asp:Button ID="btnsubmit" runat="server" Text="Click Me" OnClick="btnsubmit_Click" /></asp:Panel>

Thanks & Regards

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend