Don't do a PostBack when Timer.Tick fires
Posted on 2014-02-15
Using MS Visual Web Developer Express 2010 for some basic web page construction.
I want to change the page that is displayed in an iFrame on one of my pages programmically.
I'm trying to use a .Net Timer control to see if the page displayed should be changed every 15 seconds. That part is working. The problem is that even when the iFrame's page shouldn't be changed, the entire page the iFrame is on is being recreated every 15 seconds.
I'm guessing the Timer.Tick event function works by triggering a PostBack to the page? (I'm new to web programming so forgive me if my understanding of the concepts is incomplete)
How can I check every 15 seconds, but only recreate the page (or better yet, the iFrame) if the contents of the iFrame need to be changed. Maybe move the code that checks the need to change in the iFrame should go in the PageLoad event rather than the Timer.Tick event? And then only run the PageLoad event if the iFrame has changed?