@bobnoordam

ENTER key behaviour in ASP.NET

The behaviour of the ENTER key in an ASP.NET application can vary greatly between browsers and versions. Worse: It can change depending on the content of your page. Depending on this browser and version, you may also observe the form getting submitted, but the event handler code not executed…

Especialy when using a pagemaster you will generaly observe the enter key taking a “wrong turn”, and use one of the buttons on the master page instead of your form.

By encapsulating parts of your application in a PANEL object, you can define the default button to be used for that section of the web page. Each panel can define it’s own defaultbutton for that specific section.

<asp:Panel ID="Panel1" runat="server" DefaultButton = "Button1">
 
      ...
    
</asp:Panel

You can use the same technique to prevent a default button behaviour. If you want the enter key to do nothing at all, you can point the enter key default to a hidden button that does nothing.

<asp:Panel runat="server" ID="PanelPopupEditor" Visible="False" CssClass="blockPopup" DefaultButton="nothing">
     <asp:Button runat="server" ID="nothing" Enabled="False" Style="display: none;" />