---
title: "timer control not working in ascx page"  
description: "timer control not working in ascx page"  
author: "Anonymous User"  
published: 2015-04-02  
updated: 2015-04-02  
canonical: https://www.mindstick.com/forum/23074/timer-control-not-working-in-ascx-page  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# timer control not working in ascx page

it works in [aspx page](https://www.mindstick.com/forum/218/how-do-i-create-an-aspx-page-that-periodically-refreshes-itself) but does not [fire](https://yourviews.mindstick.com/view/81364/assam-oil-well-fire-accident-why-we-are-prone-to-it) in [ascx](https://www.mindstick.com/forum/351/how-to-pass-data-from-controller-to-ascx-page) control. here is the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) of ascx. Please let me know what I am missing. All the remaining [controls](https://www.mindstick.com/articles/66/how-to-create-controls-at-run-time-in-csharp-dot-net) fire but the [timer](https://www.mindstick.com/articles/52/creating-timer-at-runtime-in-c-sharp-dot-net) does not fire in my aspx page:

```
   
<asp:ScriptManager ID= "SM1" runat="server"EnablePartialRendering="true"></asp:ScriptManager><asp:UpdatePanel id="updPnl"runat="server" UpdateMode="Conditional"  ChildrenAsTriggers="TRUE"><Triggers><asp:AsyncPostBackTrigger ControlID="timer1"EventName="Tick"  /> </Triggers><ContentTemplate>  <asp:Timer ID="timer1" runat="server" Interval="1000" OnTick="timer1_tick"></asp:Timer>    <asp:Label ID="lblTimer" runat="server" Interval="1000" Enabled="False"></asp:Label>  protected void Page_Load(object sender, EventArgs e)        { if (!SM1.IsInAsyncPostBack)               
Session["timeout"] = DateTime.Now.AddMinutes(5).ToString();            if(!IsPostBack)            {               
//ScriptManager.RegisterStartupScript(this, this.GetType(),
"test", "javascript:f1();", true);               
fillQuestionsLabel();                
timer1.Enabled = true;            }         }        protected void timer1_tick(object sender, EventArgs e)        {            if (0 >DateTime.Compare(DateTime.Now,DateTime.Parse(Session["timeout"].ToString())))            {               
lblTimer.Text = "Number of Minutes Left: " + ((Int32)DateTime.Parse(Session["timeout"].               
ToString()).Subtract(DateTime.Now).TotalMinutes).ToString();            }        }
```

## Replies

### Reply by Anonymous User

Hi Monaj,\
The timer references Timer1 but when the user control gets rendered it will have a newly assigned name because it is on a user control. Do a View Source and you will see this is the case\
\

```
<asp:AsyncPostBackTrigger ControlID="timer1" EventName="Tick"  />
```

Add ClientIDMode="Static" as shown below. This assumes this control is only dropped on the [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) one time, otherwise you should set ControlID of timer1 postback triggers to Timer1.ClientID()

```
<asp:Timer ID="timer1"
ClientIDMode="Static" runat="server"
Interval="1000" OnTick="timer1_tick"></asp:Timer>
```


---

Original Source: https://www.mindstick.com/forum/23074/timer-control-not-working-in-ascx-page

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
