Wednesday, March 28, 2012

changes to adding ScriptReference?

Greetings! I have a javascript file that does some rounded corners on my page called rounded.js. In Beta1 I declared it like this

<asp:ScriptManager ID="ScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Path="~\rounded.js" /> </Scripts></asp:ScriptManager>

This is inside my Master Page. After the content place holders, at the end of the master page I have this.

<script type="text/javascript"> Rounded('header',6,6); Rounded('navigation',6,6); Rounded('content',10,10); Rounded('navigationright',6,6); Rounded('footer', 6, 6); </script>

It worked great with Beta1 but doesn't in Beta2. There are no rounded corners, and the javascript error reads:

Sys.ScriptLoadFailedException: The script 'rounded.js' could not be loaded or does not contain the Sys.Application.notifyScriptLoaded() callback.

Now, if I navigate with the back and forward buttons to pages inside my app, I still get the error, but the script does load somehow, because the rounded corners are there.

Please help!

Check out the release notes for the ASP.NET AJAX Extenstions (C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\ReleaseNotes.txt)...

Under "4.3: Client Framework" you will see some notes about "* Script loading improvements". Relevant to your situation: "Component developers and page developers creating file-based script libraries that are registered with the ScriptManager control should include a JavaScript code snippet that indicates that the library has been downloaded by the client. Although this is not required in all browsers, Safari requires this to be able to dynamically load scripts."

Try adding this line to the very end of your 'rounded.js' file:

if(typeof(Sys) !='undefined') Sys.Application.notifyScriptLoaded();

Thanks,
Kyle


Is the CTP libraries also need this change?

I use this code to reference CTP libraries:

1<asp:ScriptManager ID="ScriptManager1" runat="server" >2<Scripts>3<asp:ScriptReference Path="~/PreviewDragDrop.js" />4<asp:ScriptReference Path="~/PreviewGlitz.js" />5<asp:ScriptReference Path="~/PreviewScript.js" />6</Scripts>7</asp:ScriptManager>
is it right? I copied these files to my site's root directory.
and I also got the "script could not loaded" exception while running...

hello.

well, i think the value added bits don't notify the sys.application object on completion of the load. so, you can add that line to the files or you can add them to the page through the <script> element.


hey all

im having the same problem now ive upgraded :-(

The solution was to add the following line:

if(typeof(Sys) !='undefined') Sys.Application.notifyScriptLoaded();

Im still getting the same error being thrown though :-( My JS file looks like this:

function

test()
{
alert("function called");
}
if(typeof(Sys) !='undefined') Sys.Application.notifyScriptLoaded();

and i call the script like this:

<

Scripts>
<asp:ScriptReferencePath="JScipt.js"/>
</Scripts>

What am i doing wrong??

Cheers Will


hello,

make sure IE is not caching the js file.


hey - thanks for the quick reply!

Yeh i just tried clearing out all the IE cache, but its still moaning :-(

What else could i be doing wrong?


hello.try debugging the page and make sure that the call to notifyscriptloaded is being made.

ok im getting somewhere!

i tried changing the script path on my test project to an absolute path

before: Path="JScript.js"

after: Path="http://localhost:2303/AjaxControlToolkitWebSite1/JScript2.js"

all works fine! this is not summet i want to do, so why is not looking in the wrong place?

Cheers for ya help dude

Will


hello.

i've been having some problems with the internal server, ie, i'm having several issues with the caching of files when i use the internal server.


I am having the exact same problem with the internal server caching files...did you figure out a good work around?

Thanks, Greg Benoit


hello.

wll, not really. i've started using IIS :)


What are the steps for converting an existing file based project to using IIS?? I tried and almost got it working, but when I went to login using my login control and the aspnetdb the login control reported back that my login credentials were incorrect??

Thanks, Greg

No comments:

Post a Comment