ASP.NET Setting Default 'Enter' Key Button

Problem

On an ASP.NET page I have one TextBox and two buttons (Button A and Button B) on the same ASP.NET page. I type some text into the TextBox and click the 'Enter' key. This causes Button A to be activated. I wanted to Button B to be activated.

Solution

In ASP.NET 2.0, you can use the DefaultButton property in either the Form tag or Panel Control tag (via Hussein Zahran).

Example:

<asp:Panel ID="pnlMain" runat="server" DefaultButton="btnContinue"></asp:Panel

Published Friday, February 02, 2007 6:45 PM by Tod Birdsall
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit