Search code examples
asp.neteventsbuttonclickenter

Pressing Enter on an ASP.Net Textbox to invoke button click event does not work in Chrome


I have looked all over for a solution, but have not been able to.

I have an WebForm page that contains textbox and a button (inside of a panel) that is used to filter a search. When pressing Enter after entering your criteria, it fires off the button click event.

This is a legacy application and this worked in all the browsers we've tested it on. Lately, it only works in IE 11. I made multiple attempts to get this to work in Chrome to no avail. The last implementation I used was based on this article Capturing the Enter key to cause a button click.

Is it possible to capture a key-press event (Enter) to fire off a button click event in Chrome?

Thanks. -Paul


Solution

  • Hey paul you can test the following, I've tried it and it worked with me, the panel one worked for me and it worked before in chrome:

    put your wanted textbox that you wanted to work with the enter inside a panel and choose the default button for the panel to the id of the button you wanted like this:

    <asp:Panel ID="p1" runat="server" DefaultButton="b1">
             <asp:TextBox ID="t1" runat="server"></asp:TextBox>
    
            </asp:Panel>
        <asp:Button ID="b1" runat="server" />