OnKeyPress = "reload page"

Discussion in 'ASP .Net' started by Guest, Aug 24, 2005.

  1. Guest

    Guest Guest

    Hi

    I've got the following in my aspx

    <asp:textbox id="findwhat" OnKeyPress="javascript:suggest()"></asp:textbox>

    and the suggest function

    function suggest()
    {
    getElementById[btnfind'].click();
    }

    btnfind is an asp:imagebutton control, with a handler in the codebehind. So
    in theory, typing in the box performs whatever action pressing that button
    does. Except it doesnt. It reloads the page, completely.

    Any idea whats going on!?

    Cheers


    Dan
     
    Guest, Aug 24, 2005
    #1
    1. Advertisements

  2. Guest

    Guest Guest

    Tried 3 different implementations of AJAX and none of them work for me!
    Anyway, fixed it now cheers.

    Problem now is how to put the cursor back into the textbox after refresh -
    without selecting the text. Any thoughts?

     
    Guest, Aug 24, 2005
    #2
    1. Advertisements

  3. Dan,

    btnfind is a server button and as such it causes a postback. Consider using
    Ajax.

    Eliyahu

     
    Eliyahu Goldin, Aug 24, 2005
    #3
  4. <body onload='findwhat.focus()'>

    Eliyahu

     
    Eliyahu Goldin, Aug 24, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.