Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Defaulting button for submit during grid edit
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01186064
Message ID:
01186151
Views:
21
>I have a webform with a grid... When user does the "select" record and it goes to edit mode, when the user enters the value and hits enter, the "default" button on the form is a link to another page instead of the "update" or "cancel" buttons... How can I force the default button during an "edit" mode.

There's no concept of a default button in HTML so there's no automatic way to do this. The only way that you can do this realistically is use some java script and monitor keystrokes, then when you get an Enter key 'click' the appropriate button.

Something like this:
< script >
function SubmitOnEnter(event)
{
  if ( event.keyCode == 13 )
    document.getElementById('btnSubmit').click();
  
}
</ script >
which you can then call from any control that should submit on enter with:
<asp:TextBox runat="server" id="txtName" onkeyup="SubmitOnEnter(event)" />
Little more work is required to get the name of the submit button though <s>...
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform