Bizarro event handler behavior

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I'm having problems with an event handler as it handles the fired event.
The symptoms are so bizzare that they are hard to describe.

I step through the code as it runs and I see that the event fires (it's
a timer event) in my class library. In my web app I see control go to
the handler - "yippee" I think. Not so fast.

The handler then steps through each line and appears to be executing
them, but not. For instance, I'll try to change the text attribute of a
label and it won't apply the change to the label. Why? Who the hell
knows, since intellisense tells me as I step through it that it did
change the text attribute to "XYZ", or whatever. Internally the text has
changed, but it won't apply to the label on the screen. Does that make
any sense? Bizarre.

I also tried setting a Session variable, a simple string, in this
handler and that works. It sets a value and later in the program the
value is available to another procedure. Cool.

But if I try to set the label.text to that string in the Session
variable, it just doesn't do it. Not cool. I tried using other
controls, like a textbox and got the same result.

I tried Response.Write and calling a script Alert, and each line seems
to execute without any outward evidence or changes. I am apoplectic
over this - it just makes no sense to me. Anybody with a clue that can
help this poor, lost soul?
 
complete logic error on your part.

while the event fired by timer can change the page controls to its hearts
content, its too late to see the changes in the browser because the page has
already been rendered (that ship has sailed).

if you want to use a timer in your code behind, and have it effect the
rendered page, then you need to do a wait somewhere in the code behind (say
page load) until the timer has fired. of course the waiter better not be too
long, or the page will timeout, or the user will get bored of waiting for
the page to render.

-- bruce (sqlwork.com)
 
Bruce, thanks for the explanation. I am having problems transitioning
to web forms, and this is a classic example.

Classic, huh? But thanks, this does help. ~P
 
Back
Top