1

Save Fileds When Clicked on ENTER Key from KeyBoard

Hi, Here in my screen i have few fields where i need to save to Database when clicked on ADD BUTTON , But i want to save those fields when i click on ENTER Key From Keyboard. When i enter all fields and click on ENTER key from keyboard all those fields must get saved to Data Base, how can I achieve that?

Any Help is appreciated

Out
  • 627
  • 2
  • 13
  • 20

2 Answers2

1

"defaultButton" property. This can be applied to a asp:Form or asp:panel and will allow to to determine which button event should be triggered when the user hits the enter key

Example

<asp:panel defaultbutton="button2" runat="server">
        <asp:textbox id="textbox3" runat="server"/>
        <asp:button id="button2" runat="server"/>
    </asp:panel>

Hitting the Enter Key to submit a form in ASP.Net

Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
  • I tried these way ,but when i focus on text box only that key event is getting fired.., – Out Feb 21 '13 at 06:37
  • When i have 2 text boxes and just click on Enter key its not getting fire, and more over when i focus on one textbox only that RFV is getting fired, so here again i need to focus on all text boxes to get validation or enter some data – Out Feb 21 '13 at 06:39
  • @Pink - check this answer ...http://stackoverflow.com/questions/3466980/enter-key-in-asp-net-firing-wrong-button – Pranay Rana Feb 21 '13 at 06:41
  • Here when i use Tab its working..., Bcoz as tab is getting focused on each Text box....And thanks for Answer – Out Feb 21 '13 at 06:58
0

For a complete page You can use FORM Property -

<form id="form1" runat="server" defaultbutton="Button1">
    <div>
       <asp:Button Id="Button1" runat="server" Text="ADD"></asp:Button>
    </div>
</form>
Princee Singhal
  • 29
  • 1
  • 1
  • 6