Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Textbox enter keypress working in FF3 but not FF2

Options
  • 11-03-2009 12:33pm
    #1
    Registered Users Posts: 2,790 ✭✭✭


    Hi,

    I have the following piece of code in my ASP.NET Page_Load event:
    txtSearchTerm.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.ClientID + "').click();return false;}} else {return true}; ");
    

    This works in FF3 and IE7, but not FF2. Anyone have any ideas why not? :confused:

    Thanks in advance


Comments

  • Registered Users Posts: 2,790 ✭✭✭John_Mc


    up ya go


  • Registered Users Posts: 6,494 ✭✭✭daymobrew


    What is the HTML that is output by your ASP script?


  • Registered Users Posts: 2,781 ✭✭✭amen


    use jquery!

    these type of problems used to drive me mad.

    jquery eliminates a lot of them


  • Registered Users Posts: 11,977 ✭✭✭✭Giblet


    Either use an asp Panel with default button, or if that doesn't work, try setting the onClick to location.href="blah.html" and call the onClick via javascript. You can't actually use click() in firefox unless you use an input button like a submit button. The other method is to use an asp:button and hide it, and call the server side OnClick on that using the asp Panel to set it as the default button. Stuff like linkbuttons which render to an anchor tag have trouble with this :/


  • Registered Users Posts: 2,790 ✭✭✭John_Mc


    Hi Guys, Thanks for your replies :)
    daymobrew wrote: »
    What is the HTML that is output by your ASP script?
    On Page_Load I'm injecting the JS using:
    txtSearchTerm.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.ClientID + "').click();return false;}} else {return true}; ");
    

    This results in the following being rendered in HTML:
    <input type="text" onkeydown="if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('ctl00_ctl01_cph_cphHeader_oHeader_oReportRange_rsRangeSearch_btnSearch').click();return false;}} else {return true}; " id="ctl00_ctl01_cph_cphHeader_oHeader_oReportRange_rsRangeSearch_txtSearchTerm" name="ctl00$ctl01$cph$cphHeader$oHeader$oReportRange$rsRangeSearch$txtSearchTerm"/>
    
    amen wrote: »
    use jquery!

    these type of problems used to drive me mad.

    jquery eliminates a lot of them

    Afraid that's not an option at the moment :(
    Either use an asp Panel with default button, or if that doesn't work, try setting the onClick to location.href="blah.html" and call the onClick via javascript. You can't actually use click() in firefox unless you use an input button like a submit button. The other method is to use an asp:button and hide it, and call the server side OnClick on that using the asp Panel to set it as the default button. Stuff like linkbuttons which render to an anchor tag have trouble with this :/

    I setup a hidden button and declared it as default in the panel. This continued to work in FF3, IE6 & IE7 but FF2 still behaves in the same manner.

    When Enter is pressed, the panel extends vertically by a very small bit but I have confirmed that the search event handler is not fired.

    Any other suggestions? Click() works in FF3 and I've verified that it's a valid method on the Firefox website.


  • Advertisement
  • Registered Users Posts: 2,790 ✭✭✭John_Mc


    Any ideas on this lads?


Advertisement