all groups > dotnet general > april 2007 >
You're in the

dotnet general

group:

values lost on postback when using ENTER key, help


values lost on postback when using ENTER key, help JP
4/5/2007 6:26:01 PM
dotnet general:
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


--
JP
Re: values lost on postback when using ENTER key, help marss
4/6/2007 2:42:54 AM

[quoted text, click to view]


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();
AddThis Social Bookmark Button