In my masterpage, i'm having one textbox for searching purpose. if we press enterkey it is redirecting to some otherpage. But it is happening only one time. next time when i enter some text and press enter key, it is not going to the Keydown event handler.
Code:
javascript Code:
function SearchQuestionsAndDisplay(txt, event) {
if (event.keyCode == 13) {
document.location = "BrowserAddOn.aspx?SearchString=" + escape(txt.value);
}
return开发者_如何学JAVA false;
}
Text Box:
<asp:TextBox ID="SearchTextBox" runat="server" Text="Search" AutoPostBack="true"
onkeyup = "return SearchQuestionsAndDisplay(this,event)" CssClass="searchtxtbox" />
Please suggest me what i need to do. pl let me know if there is anything missing in my code.
I would look at the jquery implementation. See this: http://api.jquery.com/keypress/ and this http://api.jquery.com/keydown/
I believe FireFox and IE handle keypress differently in plain-old javascript.
精彩评论