You will need to use the client timer (or some other method) so that the browser requests an update from the server, for example, this simplified example:
<asp:UpdatePanel ID="up" runat="server"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="timer_Ticked" /> <asp:Label ID="Label1" runat="server" Text="1" /> </ContentTemplate> </asp:UpdatePanel>
Then in your code:
protected void timer_Ticked(object sender, EventArgs e) { Label1.Text = (int.Parse(Label1.Text) + 1).ToString(); }
If you have a background process that updates some state, you need to either save the general state in the session, or in the http cache, or in the database. Please note that the cache can expire due to many factors, and background threads can be killed by any link if IIS is processing the application pool.
Jason
source share