values lost on postback when using ENTER key, help

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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();
 
Back
Top