I have an update panel in my master page in a webforms application, now I have set this update panel to refresh every 5 seconds so as to reflect an updated count of row items. Some thing like the number of new messages. My questions are:
My label is getting its value from an ExecuteReader
query from my code-behind.
Yes, you can refresh after five seconds or on any interval with Timer
control without degrading performance.
Here's an example with an interval:
HTML Markup:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<!-- your controls in panel -->
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick"></asp:Timer>
Code-Behind:
protected void Timer1_Tick(object sender, EventArgs e)
{
// your stuff to refresh after some interval
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With