values lost on postback when using ENTER key, help

G

Guest

Using C# and JavaScript Framework 2.0

My users want to be able to start a search by clicking the enter key. Since
the page uses View control, I placed an onkeypress event on the table for
each view to check for keyCode 13. If it detects the enter key, then it calls
a JS function that does some validation and then calls the button click that
should have been fired for the active view. For example:

document.getElementById("ctl03_btnSmartSearch").click()

Everything works great. Both my OnClientClick and OnClick attributes for the
button appear to fire. On the postback though, all my values are gone. I cant
even Request them. But if I physically click the same button with the mouse,
all my values are there. Is there a view state or something I missing that
needs to occur when I call the click via JS verses using the mouse to click
the button?
help
 
M

marss

JP said:
Using C# and JavaScript Framework 2.0

My users want to be able to start a search by clicking the enter key. Since
the page uses View control, I placed an onkeypress event on the table for
each view to check for keyCode 13. If it detects the enter key, then it calls
a JS function that does some validation and then calls the button click that
should have been fired for the active view. For example:

document.getElementById("ctl03_btnSmartSearch").click()

Everything works great. Both my OnClientClick and OnClick attributes for the
button appear to fire. On the postback though, all my values are gone. I cant
even Request them. But if I physically click the same button with the mouse,
all my values are there. Is there a view state or something I missing that
needs to occur when I call the click via JS verses using the mouse to click
the button?
help


If I understand it correctly it occurs when user types a search
keyword and then presses Enter?
It can happens because onchange event occurs only after you leave the
input field. As a variant you can try to focus the btnSmartSearch
button.
Example:
document.getElementById("ctl03_btnSmartSearch").focus();
document.getElementById("ctl03_btnSmartSearch").click();
 

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

Top