Hi,
I have ceheck box when it cfecked on OnCheckedChanged event I set the timer as follow:
_timer.Enabled = true; and when is unchecked _timer.Enabled = false;
In checked mode i redresh the label with new date time.
When ceheck box is checked and press f5 the timer working as expected.
But when check box is unchecked and press f5 the timer continue working instead of stopping
althouh I set _timer.Enabled = false in page load when check box was unchecked .
protected void Page_Load(object sender, EventArgs e) { if (Session[STR_IsAutomaticRefreshMode] != null && (bool)Session[STR_IsAutomaticRefreshMode] == false)
{
_timer.Enabled = false;// here UpdateTargets(); } }
Why?
The aspx page:
<body> <form id="form1" runat="server"> <div> <div class="_chkRefreshModeDiv"> <asp:CheckBox ID="_chkRefreshMode" runat="server" Text="Automatic Refresh Mode" OnCheckedChanged="OnRefreshNode" Checked="true" AutoPostBack="true" /> </div> <asp:HiddenField ID="_hiddenFieldForChkRefreshMode" runat="server" EnableViewState="true"/> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Timer ID="_timer" runat="server" ontick="OnTimerTick" Interval="5000" > </asp:Timer> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="_lblTime" runat="server" Text=""></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="_timer" EventName="Tick" /> </Triggers> </asp:UpdatePanel> </div> </form> </body>