This is just the behavior of the browser. When a single line text box
(as opposed to a multiline text area) has focus and the user presses the
enter key the browser triggers the first submit button on the page. You
may be able to intercept the keystrokes for the page and "eat" the
keypress, or perhaps you could put an inocuous "bogus" button on the
page as the first button and disable it's ability to submit. Both of
these solutions would require javascript. I've never done this myself,
but I remember a team member creating an IE behavior to do the "eat",
but that only worked in IE (the company requirements allowed this).
Sorry I can't be more help.
Have A Better One!
John M Deal, MCP
Necessity Software
djc wrote:
Hi Scott, thanks for the reply.
I'm still a little confused on the behavior of hitting ENTER. 1) What event
fires when hitting ENTER when the focus is in a text box? 2) I have
autopostback set to false but a post back still occurs. Can I prevent this
postback from happening? Since nothing actually happens in my app the
postback may confuse the user.
thanks again.
"Scott M." <s-***@nospam.nospam> wrote in message
news:uI**************@TK2MSFTNGP09.phx.gbl...
The postback occurs because you hit ENTER, it is not caused by the
textbox.
If you had written code in the textbox's server event: TextChanged, then
that event would fire but the fact that you changed the text isn't what
caused the postback.
If you don't want to handle an event, simply don't write an event handler
for that event.
"djc" <no***@nowhere.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
I noticed that after entering text into a textbox on an asp.net webform
and
then hitting the enter key that a postback appears to be performed.
1) what event can I write to in order to perform an action at that time?
2) How can I prevent any postback from happening on textboxes that I do
not
want to handle this event on?
any info is appreciated. Thanks.