OnKeyPress = "reload page"

G

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
 
G

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?

Eliyahu Goldin said:
Dan,

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

Eliyahu

dhnriverside said:
Hi

I've got the following in my aspx

<asp:textbox id="findwhat"
OnKeyPress="javascript:suggest()"> said:
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
 
E

Eliyahu Goldin

Dan,

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

Eliyahu

dhnriverside said:
Hi

I've got the following in my aspx

<asp:textbox id="findwhat"
OnKeyPress="javascript:suggest()"> said:
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
 
E

Eliyahu Goldin

<body onload='findwhat.focus()'>

Eliyahu

dhnriverside said:
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?

Eliyahu Goldin said:
Dan,

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

Eliyahu

dhnriverside said:
Hi

I've got the following in my aspx

<asp:textbox id="findwhat"
OnKeyPress="javascript:suggest()"> said:
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top