views:

3866

answers:

3

I am using the AjaxControlToolkit in VS2005, and it works fine. I do have some issues though, when I go to some pages I have, then click back, I get this javascript error:

'AjaxControlToolkit' is undefined

I have searched MSDN forums, and google, and tried many of the solutions, but none have worked. I have tried, EnablePartialRendering="true", and others. Short of rewriting everything and changing the workflow of my application, is there any way to find the root cause of this, or fix it?

A: 

Is that a javascript error?

I suppose it has to do with back-button support in the toolkit.

And undefined errors mostly occurs because somehow the script that contains "AjaxControlToolkit" doesn't gets properly loaded.

Thing that come to mind:

  • The order scripts get loaded, does the Toolkit gets priority?
  • When there are errors in any of the loaded scripts all the other scripts that hasn't loaded yet will simply be canceled and not gets loaded.

See the outputted HTML of the problem page, find links to all the AXD files and make sure you can download them and see valid javascripts inside.

And if you don't already, get Firefox and Firebug and you should be able to trace to the actual script line that emits the error.

Hope this helps.

chakrit
like you said, back button issues. have used fiddler/firebug. I can see the errors happening, its not loading all the jscript on the back button, but if you hit the page from a link. Not sure what I can do to get it to load up all the jscript, back button or not, without a rewrite
ScaleOvenStove
Ummm... did you use AjaxControlToolkit in other ares other than the back button support?
chakrit
+1  A: 

This may be a silly question, but did you double check to make sure you have the toolkit reference at the top of your aspx file?

(Adding from comment for ease of reading)

Try adding this to your web.config

<system.web.extensions>
    <scripting>
        <scriptResourceHandler enableCompression="false" enableCaching="false" />
    </scripting></system.web.extensions>
CodeRot
yes its referenced. It works fine if I hit the page directly or from a link, it it just getting this error on back buttons
ScaleOvenStove
This may just be a workaround..but it is something to try. Try adding this to your web.config<system.web.extensions> <scripting> <scriptResourceHandler enableCompression="false" enableCaching="false" /> </scripting></system.web.extensions>
CodeRot
A: 

As [CodeRot] said you need to ensure you have all the AJAX web.config extensions in place, this is the most commonly missed point when doing ASP.NET AJAX sites (particularly from VS 2005).

Next make sure that you have a ScriptManager on the page (which I'm guessing you do from the "EnablePartialRendering" mention).

Make sure that you are referencing the AjaxControlToolkit version for your .NET version, it is compiled for both .NET 2.0 and .NET 3.5, and I believe the latest release is only supporting .NET 3.5.

Ensure that you're getting the Microsoft AJAX Client Library added to the page (that you're not getting any errors about "Sys" missing).

Ensure that you a registering the AjaxControlToolkit in either your ASPX, ASCX or web.config.

Slace
all that is done. This is the most common answer around the web. The AjaxControlToolkit is working fine. It just throws up the jscript error on back button. I am using ajax controls from it and the work just fine otherwise.
ScaleOvenStove