views:

174

answers:

2

I have a ton of update panels and such on my webform (which are created dynamically at runtime)

I am wanting to put a locking timer or something similar in my form also. My problem is this. When someone is typing into a text box, and the timer happens they lose part of their text and the control loses focus.

The reason this happens is because on post back some things are done and the screen is rebuilt and the current control panel is updated. The reason this happens is because the only things that would cause the page to get refreshed prior to this timer were Change events on the controls(in which things need to be checked and updated). So what I need is to know if this Lock Timer is what caused the refresh so that I don't rebuild the screen or touch anything else like that. I can't wait until it gets to the Tick event because by the time it's there the screen has already been rebuilt and messed up for the user.

Also, I can't use viewstate or any other magic, as the screen is rebuilt at Page_Init. I checked if sender would say the timer, but it only gives the current page..

So my question is this:

How do you tell if the reason a refresh happened is because of an update timer at Page_Init?

+2  A: 

How about Request.Form["__EVENTTARGET"]?

Matt Hamsmith
doesn't work for buttons or imagebuttons
Christopher Kelly
That gives me a string of generated IDs, not the ID of my timer..maybe I could make it work with another panel though..
Earlz
No, that gives me <pageid><contentid(from masterpage)><toplevel container of content> which does not give me enough information to deduce if it was from the timer..
Earlz
Actually I was wrong.. I didn't do a full refresh when testing that.. I will just get Request.Form["__EVENTTARGET"].Contains("LockTimer");
Earlz
@Christopher - Understood, but earlz isn't looking for a button or an imagebutton. Great link in your answer, however. I used that very same web page for a problem earlier today.
Matt Hamsmith
A: 

see the following page How to determine which Control caused PostBack on ASP.NET page?

Christopher Kelly
It seems that timer controls are not even added to that list in Form. I looked through `allkeys` and did not find my timer I set...
Earlz