Saturday, March 24, 2012

Events inside an UpdatePanel

I'm still fairly new to Ajax so please bear with me. I have an updatepanel that has a bunch of user controls in it that are added dynamically and have their events wired up to some of my methods. What I'm trying to figure out is the order in which callbacks work. For example, I have a radio button with the click event wired up and a textbox with the text changed event wired up. If I type in some text and then click the radio button the text event fires, then the click event fires, then the text event fires again. This is how it runs when I'm using studio, but when I deploy to our production site it seems that the click event fires then the text event and that's it. I actually like the first behavior because it maintains my data structure. Could someone shed light on what it's "supposed" to do and why I get two different behaviors?

Thanks,

Jim

Hi Jim,

It's strange. The order of the controls' event is determined by the ASP.NET, it has nothing to do with which server that it resides in.
A possible cause is with the form of the posted data.
For example, to post "textbox1=value1&1=Radiobutton1" may cause the events to fire in different order from posting "1=Radiobutton1&textbox1=value1".
You can useFiddler?or?Web?DevHelper?to?moniter?the?traffice?to?make?it?clear.

Hope this helps.
I have figured out that the ordering is definitely determined by the order in the page control structure. I'm assuming the control structure is traversed and that each control's events are checked, that's at least seems what happens. What I can't seem to figure out is why when I'm using studio events fire more than once. I got it tod do what I want now so I guess that's all that matters for now.
This is weird, can you show me a stripped version of your code that can reproduce the issue?
It's hard for me to trouble shooting without detail information.

No comments:

Post a Comment