ASP.NET Timer only works in debug mode
Asked Answered
B

2

6

I am using the ajax timer control inside an update panel.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"></asp:Timer>            
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    </ContentTemplate>
</asp:UpdatePanel>

The timer should update the label every second with the current datetime.

    protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label1.Text = DateTime.Now.ToString();
    }

Everything works fine in debug mode but when I run the site without debugger (CTRL+F5) or if I deploy the site to my server the timer does not tick.

But when I add "debug=true" to the web.config everything works fine. Even on my server.

<compilation targetFramework="4.0" debug="true">

Internet Explorer throws the exception "Object doesn't support this action" in ScriptResource.axd.

How can I solve this issue?

EDIT: I think I have solved it.

I don't know why but two things can solve this issue:

  • Using a ScriptManager instead of a ToolScriptManager
  • Using the ToolScriptManager with CombineScripts="false"

I have no clue if this is a bug or not.

Maybe somebody can explain it.

Bongbongo answered 15/2, 2014 at 12:6 Comment(0)
L
2

There seems to be a bug in the latest AJAX Control Toolkit - I have just come across this error myself - It seems the only option is to downgrade to a previous version.

https://ajaxcontroltoolkit.codeplex.com/workitem/27639 and http://forums.asp.net/t/1962717.aspx?Timer+and+Script+Combining+w+ToolkitScriptManager

to fix the current issue i am having to run in debug mode until i can downgrade and test.

Lambdoid answered 27/5, 2014 at 13:47 Comment(0)
D
1

This worked for me.

Using the ToolScriptManager with CombineScripts="false"
Donald answered 9/9, 2015 at 14:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.