开发者

KeyDown event is not firing second time

开发者 https://www.devze.com 2023-01-02 18:14 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消