Home All Groups Group Topic Archive Search About
Author
15 Jul 2006 12:21 AM
Edward Diener
I have a textbox-like control on a web form which has AutoPostBack set
to true. If I press the Submit button on my web form after changing the
text of the control, the handler for the AutoPostBack for the
textbox-like control is evoked but the handler for the Submit button is
never subsequently called in that particular postback. Does anybody know
why ? I want both handlers to be called before issuing a response back
to the client.

Author
15 Jul 2006 9:11 AM
Alessandro Zifiglio
hi Edward, this behavior you are getting is due to the fact that the textbox
control is subscribed to a clientside onchange event.
In effect this the render output of a textbox control with postback enabled
:
<input name="TextBox1" type="text" value="ok dood"
onchange="javascript:setTimeout('__doPostBack(\'TextBox1\',\'\')', 0)"
onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;"
id="TextBox1" />

Behavior of the onchange event in msdn documentation :
http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onchange.asp

"This event is fired when the contents are committed and not while the value
is changing. For example, on a text box, this event is not fired while the
user is typing, but rather when the user commits the change by leaving the
text box that has focus. In addition, this event is executed before the code
specified by onblur when the control is also losing the focus."

Note the last line where its said  that the event fires "when the control
loses focus". This is exactly what is happening, when the text is changed
and you  hit the submit button, the textbox loses focus causing it to
postback, and your submit button never gets to issue a postback =P

By the way, do you really need autopostback set to true ? The textchanged
event of the textbox will fire without needing to set an autopostback
trigger, specially since you already have a submit button you might not need
this.

Regards,
Alessandro Zifiglio
http://www.AsyncUI.net

Show quoteHide quote
"Edward Diener" <eddielee_no_spam_here@tropicsoft.com> ha scritto nel
messaggio news:eZ%233TS6pGHA.5104@TK2MSFTNGP04.phx.gbl...
>I have a textbox-like control on a web form which has AutoPostBack set to
>true. If I press the Submit button on my web form after changing the text
>of the control, the handler for the AutoPostBack for the textbox-like
>control is evoked but the handler for the Submit button is never
>subsequently called in that particular postback. Does anybody know why ? I
>want both handlers to be called before issuing a response back to the
>client.