By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,631 Members | 892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,631 IT Pros & Developers. It's quick & easy.

PostBack NonPostBack Event order issue

P: n/a
On a webForm, I have a DropDownList with AutoPostBack=true and I also
have couple textbox with AutoPostBack=false.

I am expect that the DropDownList's SelectedIndexChanged event being
handled after the textboxs' TextChanged event since this is the one
that cause the PostBack.

But I got the DropDownList's event first.

Reading the document, I noticed it only mention all the change event
are handled in NO particular order, the the CLICK event that CAUSE the
POST is processed. So I can't complain much but it would be nice the
see the any event that CAUSE the post is handled last.

John
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
John Hi,

I'm little bit confused. ASP.NET post back architecture is build on two
hidden field that hold the control ID and optionally parameters that
cause post back. The server side now which control and event to call by
the hidden field that holds specific control ID thus just one event can
be call per post back. Each post back the page initialize and the PAGE
events are called before the request control event.

So I cant see how you can get events of combo box and textboxes on the
server side. You also mention that you set the textboxes autopostback to
false so they don't trigger any postback at all.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

P: n/a
Natty,

Thanks for the response, I may not user correct terms. Here is my
prolem w/ example.

On the webform, I have:
1. A dropdownlist/combo box - ddlOne, w/ AutoPostBack=true
2. A textbox - txtTwo, w/ AutoPostBack=false
Both controls have their event handlers:
ddlOne_SelectedIndexChanged, and
txtTwo_TextChanged.

I first enter some text in txtTwo. The TextChange is NOT fired
immediately because AutoPostBack is set to false. Then I select an
item from the ddlOne. And this CAUSE the POSTBACK.

Now look at the order of the events - ddlOne_SelectedIndexChanged is
alway before txtTwo_TextChanged.

I understand why ddlOne_SelectedIndexChanged happen first because
ddlOne is put one the form first. It DOESN'T MATTER who cause the
postback. Both events are StateChange event that implement the
IPostBackDataHandler interface. The runtime tracks the controls that
return true to LoadPostData and Invoke the RaisePostDataChangedEvent
in the order of the controls on the form.

So this is by design not a bug but a challenge for me. I want the
TextChanged event happen first because the ddlOne_SelectedIndexChanged
need the outcome the the text.

Or, is there any Event that I can be sure is the LAST event that I can
use?

Thanks again.

John
Nov 18 '05 #3

P: n/a
PreRender is the last event, where you can still change page rendering

-- bruce (sqlwork.com)
"Q. John Chen" <no******@wowway.com> wrote in message
news:84*************************@posting.google.co m...
Natty,

Thanks for the response, I may not user correct terms. Here is my
prolem w/ example.

On the webform, I have:
1. A dropdownlist/combo box - ddlOne, w/ AutoPostBack=true
2. A textbox - txtTwo, w/ AutoPostBack=false
Both controls have their event handlers:
ddlOne_SelectedIndexChanged, and
txtTwo_TextChanged.

I first enter some text in txtTwo. The TextChange is NOT fired
immediately because AutoPostBack is set to false. Then I select an
item from the ddlOne. And this CAUSE the POSTBACK.

Now look at the order of the events - ddlOne_SelectedIndexChanged is
alway before txtTwo_TextChanged.

I understand why ddlOne_SelectedIndexChanged happen first because
ddlOne is put one the form first. It DOESN'T MATTER who cause the
postback. Both events are StateChange event that implement the
IPostBackDataHandler interface. The runtime tracks the controls that
return true to LoadPostData and Invoke the RaisePostDataChangedEvent
in the order of the controls on the form.

So this is by design not a bug but a challenge for me. I want the
TextChanged event happen first because the ddlOne_SelectedIndexChanged
need the outcome the the text.

Or, is there any Event that I can be sure is the LAST event that I can
use?

Thanks again.

John

Nov 18 '05 #4

P: n/a
Hi,

I think I understood you. the event order set by the control order in
page HTML. if you place combo and text box and the textbox is before the
listbox. the textbox event will fired first. change the order and the
listbox event will be fired first.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5

P: n/a
Yes, PreRender works for me. Thank you both.

- John
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.