Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Autopostback and submit button

0 views
Skip to first unread message

Edward Diener

unread,
Jul 14, 2006, 8:21:10 PM7/14/06
to
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.

@-h-o-t-m-a-i-l-c-o-m Alessandro Zifiglio

unread,
Jul 15, 2006, 5:11:09 AM7/15/06
to
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

"Edward Diener" <eddielee_n...@tropicsoft.com> ha scritto nel
messaggio news:eZ%233TS6p...@TK2MSFTNGP04.phx.gbl...

0 new messages