locked
Timer and Script Combining w/ ToolkitScriptManager RRS feed

  • Question

  • User-125377524 posted

    I think I've found a bug with how script combining works with the Timer control.  Although, this is so basic that I'm wondering if anybody can see if I'm doing something wrong.  I want to use a Timer control with a ToolkitScriptManager.  When script combining is turned off, everything works fine. But by changing the ToolkitScriptManager.CombineScripts property to true, the Timer control never fires the Tick event.  If I debug the javascript, I see an error message saying "undefined is not a function".  The code is very simple:

    <%@ Page Language="VB" %>
    <%@ Register TagPrefix="ajax" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
    <script runat="server">
    
    Protected Sub tmrTest_Tick(Sender As Object, Args As EventArgs)
     Dim objLabel As Label = CType(FindControl("lblTest"), Label)
     objLabel.Text = (CInt(objLabel.Text) + 1).ToString()
    End Sub
    
    </script>
    <html>
    <body>
    <form runat="server" id="frmTest">
     <ajax:ToolkitScriptManager runat="server" id="scpManager" EnablePartialRendering="True" CombineScripts="True" />
     <asp:Timer runat="server" ID="tmrTest" Interval="2000" OnTick="tmrTest_Tick" />
     <asp:UpdatePanel runat="server" id="upnlTest">
      <ContentTemplate>
       <asp:Label runat="server" ID="lblTest" Text="1" />
      </ContentTemplate>
     </asp:UpdatePanel>
    </form>
    </body>
    </html>
    

    If you change the CombineScripts property to False, it works fine.  When the value is True, it fails.  I've made sure the CombineScriptsHandler.axd handler is registered in my web.config, but this just doesn't work.  Can anybody give me a little guidance on this, or is this a known issue?

    Tuesday, January 21, 2014 11:44 AM

Answers

  • User1734617369 posted

    Hi,

    I can confirm that this is a bug, the problem is that when the combine script is active the script resources are not being loaded in the correct order, the same happens if you remove the CombineScript attribute but uses the ScriptMode="Release".

    Best regards
    Johan

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 23, 2014 10:02 AM

All replies

  • User-417640953 posted

    Hi Bryan,

    Thank you post the issue to our forum.

    I test your code and it works fine to me. There is a similar bug you can refer to.

    "CombineScripts=true compatibility problems in IE" with solutions below.

    http://ajaxcontroltoolkit.codeplex.com/workitem/15245

    "undefined is not a function"

    For the error message, I suggest you try remove Microsoft.AspNet.ScriptManager.MSAjax.dll from bin folder on the server if it exists.

    More information, please check below link.

    http://timscyclingblog.wordpress.com/2013/03/22/ajaxcontroltoolkit-version-7-0123-with-net-4-5/

    Hope this helps, thanks.

    Best Regards!

    Wednesday, January 22, 2014 4:50 AM
  • User-125377524 posted

    To make the code not work, you need to take the site out of debug mode.  When the site is in debug mode, it works just fine because script combining doesn't function in debug mode.  However, in release mode, the code does not work.  I've been able to get the code to fail by using the following web.config:

    <?xml version="1.0"?>
    <configuration>
     <system.web>
      <compilation debug="false" strict="true" explicit="true" targetFramework="4.0" />
     </system.web>
    </configuration>

    When debug="false" in the web.config and CombineScripts="True" for the ToolkitScriptManager, the timer doesn't tick.  Are you able to get this to work using this configuration?

    Thursday, January 23, 2014 8:47 AM
  • User-125377524 posted

    Hitting Ctrl-F5 doesn't help the problem.  I've been able to successfully reproduce this issue using the example previously uploaded in this thread.

    Thursday, January 23, 2014 8:48 AM
  • User1734617369 posted

    Hi,

    I can confirm that this is a bug, the problem is that when the combine script is active the script resources are not being loaded in the correct order, the same happens if you remove the CombineScript attribute but uses the ScriptMode="Release".

    Best regards
    Johan

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 23, 2014 10:02 AM
  • User-125377524 posted

    Thanks, do you know if it's an issue which is being worked on by the AJAX Control Toolkit group?  Script combining is such a useful tool; it's a shame not to be able to use it on my websites!  I entered an issue on CodePlex, but who knows if anybody will see it who can fix the issue.

    Thursday, January 23, 2014 11:00 AM
  • User1734617369 posted

    Hi,

    I don't know if they have checked into this issue yet, there seems to be quite a lot of issues with the latest release so I think it will take some time before this issue is fixed.

    /Johan

    Friday, January 24, 2014 2:26 AM