ASP.NET Timer仅在调试模式下工作

时间:2014-02-15 12:06:26

标签: c# asp.net ajax timer scriptmanager

我在更新面板中使用了ajax计时器控件。

<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>

计时器应该每秒用当前日期时间更新标签。

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

在调试模式下一切正常但是当我运行没有调试器的站点(CTRL + F5)或者我将站点部署到我的服务器时,计时器不会打勾。

但是当我在web.config中添加“debug = true”时,一切正常。甚至在我的服务器上。

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

Internet Explorer在ScriptResource.axd中抛出异常“对象不支持此操作”。

我该如何解决这个问题?

编辑:我想我已经解决了。

我不知道为什么但有两件事可以解决这个问题:

  • 使用ScriptManager而不是ToolScriptManager
  • 将ToolScriptManager与CombineScripts一起使用=“false”

我不知道这是不是一个错误。

也许有人可以解释一下。

1 个答案:

答案 0 :(得分:2)

最新的AJAX Control Toolkit中似乎存在一个错误 - 我自己也遇到过这个错误 - 似乎唯一的选择是降级到以前的版本。

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

修复当前问题我必须在调试模式下运行,直到我可以降级并测试。

相关问题