How to tell if a refresh came from a Timer (C#)

天涯浪子 提交于 2019-12-24 12:06:46

问题


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?


回答1:


How about Request.Form["__EVENTTARGET"]?




回答2:


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



来源:https://stackoverflow.com/questions/1468199/how-to-tell-if-a-refresh-came-from-a-timer-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!