问题
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.
回答1:
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.
回答2:
This worked for me.
Using the ToolScriptManager with CombineScripts="false"
来源:https://stackoverflow.com/questions/21797310/asp-net-timer-only-works-in-debug-mode