Want to work with us? We're on the lookout for digital experts.

We're hiring

Enter Key Press On Control Firefox Issue ASP.Net

Web Bureau

17 November 2010 by Web Bureau

.NET Framework 3.5

Been having an issue trying to sort this problem out. The scenario is that i have multiple textboxes on screen that should replicate the mouse click submit behaviour on a button when the enter key is pressed.

Everything i tried didnt work until i found this piece of code below. I think it incorporates 2 solutions on is the use of a panel around the text box in question with the default button set and the other is the inclusion of the javascript file.

I hope this is of use to others with the same issue.

<asp:Panel ID="pnl_Search" DefaultButton="btn_Search" runat="server">

                   <div class="txtbox_outer"><asp:TextBox ID="str_Search" runat="server" CssClass="txtbox"></asp:TextBox></div>

                   <div class="signin_btn"><asp:LinkButton ID="btn_Search"  runat="server" CssClass="search_btn" Text="Search"></asp:LinkButton></div>                 

                   <cc2:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="str_Search" WatermarkText="Enter Search Text..."></cc2:TextBoxWatermarkExtender>


 // Javascript Fix for enter key press firefox ====================

  $(function () {
         var b = document.getElementById('<%= btn_Search.ClientID %>');
         if (b && typeof( == 'undefined') {
   = function() {
               var result = true;
               if (b.onclick) result = b.onclick();
               if (typeof(result) == 'undefined' || result) {



Grow your businessStart a project with us today.

This site uses essential cookies for parts of the site to operate and have already been set. Find out more about how we use cookies and how you may delete them. You may delete cookies, but parts of the site will not work.