I am developing an asp.net website. I have an asp:Timer control to update the page for every 10 minutes. I did that setting the interval property as shown below..
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="100000" Enabled="True"></asp:Timer>
Now I have a requirement where I need the user to select the interval period on the screen and based on what the user selects, the 'Interval' value should change.
So the user has something like this on the screen:
10 min 15 min 20 min
Clicking on any of the above time interval values, the 'Interval' value should change.
I searched online and don't seem to get any idea on how I can go forward. How can I get this done?
The solutions seem to be simple using ASP.NET Ajax Timer:
Don't use the hard-coded value in HTML (that portion Interval="100000" pointed out in previous comments). Instead, put the timer initialization in Page_Load event (!IsPostBack){ }
On every Timer.Tick event check for the content of that drop-down (or whatever control you provide to User for changing the interval) and change the interval if necessary.
2a. If you re-load the page, then you can persist the interval value either in the cookies, or session variable.
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