Tales from the Evil Empire

Bertrand Le Roy's blog

News

Ads Via DevMavens

ASP.NET AJAX UpdatePanel Control: Add Ajax interactivity to your ASP.NET 2.0 web pages

Add to Technorati Favorites

Blogs I read

My other stuff

How to work around the access denied cross-domain frame issue in ASP.NET Ajax 1.0

Some users have run into an issue when hosting ASP.NET Ajax applications in a frame or iframe that's in a different domain from the top-level window. If you try to do that and browse to the page using IE, you'll receive an "access denied" error client-side any time a DOM event is raised in the frame. The code that's responsible for that is Sys.UI.getLocation. This is a tricky piece of code that determines the pixel coordinates of a DOM element relative to the top-left corner of the page, so that an absolutely positioned child of the body using these coordinates would exactly cover the element you measured. This is useful for drag & drop, popup scenarios like auto-complete and when an event is raised to get mouse coordinates relative to the event source. This is this last piece that explains the problem. The code in this method is different for each of the browsers that we support because each one of them has its own behavior that cannot be determined as we usually do by dynamically looking at capabilities. You just have to know for example that browser X is not counting an element's scroll position if it's absolutely positioned and a direct child of body (names changed to protect the guilty). That's the kind of problem we had to work around. Luckily, IE has two very handy methods to retrieve this kind of coordinates that enables us to bypass completely a number of bugs that we just couldn't efficiently work around: getClientRects, which gets all rectangles the element occupies on the page, and getBoundingClientRect, which returns a single rectangle that bounds the whole element. In the method that we shipped, we've been using getClientRects and getting the first rectangle because we wanted to have consistent behavior across browsers even if the element is a wrapping element such as a span: in this case, the top-left corner of the element is the top-left corner of the first bounding rectangle, which is different from the top-left corner of the global bounding rectangle:

And this is where we made a mistake, unfortunately too late. There is a subtle difference between getClientRects and getBoundingClientRect, which is that getClientRects, when in an iframe, gives coordinates that include the offset of that frame in the top window, whereas getBoundingClientRect gives the right coordinates directly. Both need to include the frameborder to be perfectly accurate. To correct the behavior of getClientRects, we had to look at the coordinates of the frame relative to the top window, to subtract them, and this is the operation that is not allowed if the frames are in different domains.

The fix is to use getBoundingClientRect instead, which will introduce a small inconsistency across browsers in the case of wrapping elements but is a lot better than just failing. The new version of the function still needs to try/catch around the code that fixes the frameborder, so for cross-domain frames you may get a 2 pixel offset in the coordinates but this is the best you can get.

How to apply the fix

First, you’ll need to use the external script files instead of the resource-based ones. You do this by setting a general ScriptPath on the ScriptManager. The external script files can be found in the Microsoft Ajax Library (http://ajax.asp.net/downloads/library/default.aspx?tabid=47&subtabid=471) which is under the MSPL (which allows you to modify the files). Copy the System.Web.Extensions folder found in the Library zip into the folder you pointed ScriptPath to.

Alternatively, if you don't want to have all your script references path-based, you can point only the core framework to a file and leave the others to use web resources as usual. This makes things easier when using other resource-based libraries such as the toolkit. This is easily done by adding the following script reference to your script manager:

<asp:ScriptReference
    Name="MicrosoftAjax.js" ScriptMode="Auto"
   
Path="~/[Your Script Directory]/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js"/>

Of course, don't forget to replace the part of the path between the brackets with the name of the script directory you chose. Don't set a ScriptPath on the script manager if you choose to use this script reference. 

Once you’ve done that, you can check that the application still works and loads the script from the new location using a network monitoring tool such as Fiddler.

The second step is to patch the files. You’ll need to patch the debug and release versions.

The debug version is MicrosoftAjax.debug.js. Look for the following code:

switch(Sys.Browser.agent) {
    case Sys.Browser.InternetExplorer:

then replace everything between that and "case Sys.Browser.Safari:" with the following code:

Sys.UI.DomElement.getLocation = function(element) {
    if (element.self || element.nodeType === 9) return new Sys.UI.Point(0,0);
    var clientRect = element.getBoundingClientRect();
    if (!clientRect) {
        return new Sys.UI.Point(0,0);
    }
    var ownerDocument = element.document.documentElement;
    var offsetX = clientRect.left - 2 + ownerDocument.scrollLeft,
        offsetY = clientRect.top - 2 + ownerDocument.scrollTop;
    
    try {
        var f = element.ownerDocument.parentWindow.frameElement || null;
        if (f) {
            var offset = 2 - (f.frameBorder || 1) * 2;
            offsetX += offset;
            offsetY += offset;
        }
    }
    catch(ex) {
    }    
    
    return new Sys.UI.Point(offsetX, offsetY);
}
break;

For the release version (MicrosoftAjax.js), the process is pretty much the same except that the file is a little more difficult to manipulate. Look for "switch(Sys.Browser.agent){case Sys.Browser.InternetExplorer:" and replace everything between that and "case Sys.Browser.Safari:" with the following:

Sys.UI.DomElement.getLocation=function(a){if(a.self||a.nodeType===9)return new Sys.UI.Point(0,0);var b=a.getBoundingClientRect();if(!b)return new Sys.UI.Point(0,0);var c=a.document.documentElement,d=b.left-2+c.scrollLeft,e=b.top-2+c.scrollTop;try{var g=a.ownerDocument.parentWindow.frameElement||null;if(g){var f=2-(g.frameBorder||1)*2;d+=f;e+=f}}catch(h){}return new Sys.UI.Point(d,e)};break;

(no line breaks)

The site should now work without the exceptions.

Known issues with that fix

  • Coordinates returned by Sys.UI.DomElement.getLocation may be off by two pixels in some scenarios involving frames from different domains.
  • The patched implementation returns the upper left coordinates of the bounding box around the element instead of the upper left corner of the first rectangle of the element, which can be different for wrappable elements. This is inconsistent with what the function returns on other browsers.
  • If you enable script localization on the script manager, it will generate a request for a localized version of the Ajax script, which will not exist because we haven't shipped localized versions of the standalone script files yet. You can work around this by renaming the files MicrosoftAjax.en.js and MicrosoftAjax.debug.en.js and adding ResourceUICultures="en" to the script reference. Don't change the path or name.

Important disclaimer

This fix implies that you stop using the resource-based scripts and use the static file versions instead.  I expect this is the fix that will be in the next service release, so when the next release of System.Web.Extensions happens, you will want to revert to using the resource-based scripts to get any other fixes or changes that are made.

UPDATE: added a way to replace just the core framework file.

UPDATE 2: The toolkit had a similar bug, and now provides a similar workaround: http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx

UPDATE 3: made the release patching procedure clearer based on Atanu's comment. Apologies to everyone who hit this and thanks to Atanu for pointing it out.

UPDATE 4: added known issue with localization and how to work around it.

UPDATE 5: this is fixed in ASP.NET 3.5.

Comments

PohEe,com said:

Good article. Hopefully Microsoft will fix this ASAP. Let's wait together

# January 31, 2007 8:45 PM

Alex said:

Hm, applying this workaround confuses me a bit, because somehow, if i begin to add global path to script manager, i need to collect all scripts into one folder, which i do not want to do.

Best way is to have just core framework script modified, it looks like .net2 then wants every single script "pathed" as well... why it does not take the rest from default resources as usual?? I'm puzzled

many thanks if you can help,

Alex

# February 5, 2007 4:09 AM

alex.lee said:

(this is Alex again :)

Have managed to make this error gone for a while. A thing why the rest of script did not want to load was because VWD Express test server wants addresses in ~/path/path format, while IIS consumes /path/path . So this is fixed.

However, same "access denied" reappeared when autocomplete textbox (living inside frame) calls webservice to fill a list.

PS. Site has same as yours structure- parent page has frame with my [other domain] ajax site...

# February 5, 2007 4:41 AM

alex.lee said:

Bertrand, you seem to be my only hope :)

2 my previous posts are rather chaotic, so excuse me.

To summarise, not just your pointed framework script fails in iframe on IE, but Common script for toolbox as well:

[...] when autocomplete tries to place results, it uses this part of code of this script:

getLocation : function(element) {

[...]           <b>if (element.ownerDocument.parentWindow.frameElement)</b> {

[...]   }

===

Bold line already fails and i believe, what follows will fail as well.

So, my prob is how to correct script and where to specify path to consume corrected version? (similar to yours task)...

Many thanks!

# February 5, 2007 6:42 AM

Bertrand Le Roy said:

Alex: the code you posted is the *old, unpatched* code. So you either did not correctly set up your script reference or you didn't patch the file. You can drop me e-mail through the contact form if necessary.

# February 5, 2007 2:23 PM

Chris said:

I am having the same issue as Alex. Your patch corrected the issue with the inital page load, but now I get the same Access Denied message when any AjaxToolkit control is used. The AjaxToolkit has it's own getLocation definition, which eventually calls the Framework's getLocation but, is failing before it gets to the call. The AjaxToolkit getLocation is defined in Common.js.

# February 5, 2007 2:50 PM

Delay said:

Sorry for the trouble, Chris! Please see http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx for details on how to make the corresponding changes to the AJAX Control Toolkit.

# February 5, 2007 7:53 PM

Mike said:

Nice article, but I could never get approval to implement it this way.  I hope MS can fix this soon.  I was trying to use the AjaxControlToolkit to mask some textboxes in an iframe that was embedded on a Micrsoft CRM form.  For now, I commented out the Extenders until this can be fixed.  Still, keep up the good work.

# February 7, 2007 8:00 PM

Bertrand Le Roy said:

Mike: the next version of the toolkit will contain the fix, which may be your best best as I see you're using it.

# February 9, 2007 2:12 PM

Alpesh said:

Thanks for the article. It fixed most of our x-domain issues with RTM bits.

However, under special circumstances, I still get access denied errors.

What I have is an iFrame that has a link to a Rss feed. When I click on the feed, I get an access denied error in the addHandler method here (in MicrosoftAjax.js):

if (element.addEventListener) {

       browserHandler = function(e) {

           return handler.call(element, new Sys.UI.DomEvent(e));

       }

       element.addEventListener(eventName, browserHandler, false);

This happens only when the link is trying to open a Rss feed. Any ideas why this would happen?

# February 9, 2007 7:12 PM

Bertrand Le Roy said:

Alpesh: If you're trying to set-up an event for an element that is in a different window/frame, there is a known issue with that. Please contact me to check if that's the same problem you're hitting and how to work around it. You can use the contact form to drop me e-mail.

# February 9, 2007 7:18 PM

Thomas Coombs said:

The following error occurs when hitting links, selecting tabs on this page.  Which we determined to be a cross domain scripting issue within an iFrame.

Access is Denied

We applied the fix found above and added the “Systems.Web.Extensions” folder to our solution

Amended the appropriate JS files as per the fix

Added a ScriptPath attribute to the ScriptManager Tag to point to the relevant location

<asp:ScriptManager ID="ajaxManager" runat="server" EnablePartialRendering="true" ScriptPath="~/JavaScript/AjaxExtensions" />

Retested the page and checked the appropriate script links were all pointing to the correct and newly added path.

This tested succussfully.

However, as a result of applying this fix we encountered a new problem.  On loading the display.aspx page, the following Javascript error occurs:

Expected ';'

var $create=Sys.Component.create=function(h,f,d,c,g){var a=g?new h(g):new h,b=Sys.Application,i=b.get_isCreatingComponents();

Followed by a further error Object expected

var $create=Sys.Component.create=function(h,f,d,c,g){var a=g?new h(g):new h,

This error is occuring in the MicrosoftAjax.js file we added and modified as described above.

As a further result…  Also on this page we use a <asp:UpdatePanel> which is associated to a <asp:timer> control which handles our Polling facility to check responses we receive on a given interval.  This no longer functions, we assume the two events are linked.    

Can anyone help me?

# February 14, 2007 9:08 AM

Benny/Norway said:

I've got the same problem, but the fix didn't help me. Because I was using frameborder="no" in my iframe.

I got the NaN exception.

The only fix ==> frameborder="0"

# February 14, 2007 9:59 AM

Bertrand Le Roy said:

Thomas: I think you didn't apply the patch properly. What you replace in the release version includes the switch, but you must not replace the case Safari.

Benny: frameborder="no" is illegal XHTML. Please use "0". This is actually a different problem (which doesn't cause "access denied") so it's not surprising that the patch would not fix it.

# February 14, 2007 1:35 PM

Thomas Coombs said:

Thanks very  much for your prompt response Bertrand.

I've checked the release version of the file, but the "case Sys.Browser.Safari" does still exist.

Sorry.

# February 15, 2007 3:45 AM

Bertrand Le Roy said:

Thomas, please contact me through the contact form of this blog. I'll look at your file.

# February 15, 2007 1:53 PM

Darren said:

Does anyone have the full file working.  I am getting a Sys is undefined when using the Atlas toolkit

# February 15, 2007 5:40 PM

Carl said:

I am getting 'Type' is undefined on the first line of ScriptResource.axd.  Does this mean I misconfigured something and the js files are not being used?

# February 22, 2007 4:46 PM

Bertrand Le Roy said:

Carl: you probably made a mistake when patching the file, which created a syntax error, or you did not put the MicrosoftAjax.js and MicrosoftAjax.debug.js files at the right place.

The fact that you're seeing scriptresource.axd does not mean that the js file is not being used: if you just replaced the MicrosoftAjax.js reference, all other scripts will still use scriptresource.axd. What you want to check is if MicrosoftAjax(.debug).js is being queried and if the script tag in the html source as seen from the browser has its src attribute set to the right url.

# February 22, 2007 5:23 PM

Carl said:

I placed the entire folder System.Web.Extension in my sight then added a ScriptPath Property to the directory all the way down to the js files.  I also tried using the <asp:ScriptReference > from above.  Both result in the same issue.

I also receive the error prior to trying to path the files and after.

I just downloaded fiddler and I will try to see if I can see the debug file being accessed.

I also cleared all browser cache and cleaned my project.

# February 22, 2007 5:38 PM

Carl said:

Actually, I need more sleep and a spell checker built into the IDE.  Everything is now working all is well.  Fiddler is a great tool and showed me the 404 error when tryin to access MicrosoftAjax.debug.js.  there fore I verified the path in the script manager and realized I had added an 's' to a word.  Thanks for everything!

# February 22, 2007 5:46 PM

Darren said:

Has this now been fixed with the 3/2 release?

# March 5, 2007 10:55 AM

Bertrand Le Roy said:

Darren: what we released last week was an Orcas CTP that doesn't contain any Ajax bits, so I suppose not. It will be fixed in the first Orcas release that contains Ajax bits, which should be beta 1 as far as I know.

# March 5, 2007 3:05 PM

Fedor said:

When can we expect ASP.NET Ajax update with this fix?

# March 13, 2007 5:47 AM

Bertrand Le Roy said:

Fedor: see above comment. The next release (Orcas beta) will have the fix.

# March 13, 2007 1:56 PM

Mike Mattix said:

Thanks,

It worked like a charm.  Our problem was running AJAX applications in Page Viewer Web Parts under Sharepoint (WSS V3.0).  In case anyone else is having the same issue.  The PopupControl Extender would not fire and display the Calendar.  It would (of course) stand-along but not in the Page Viewer Web Part.

Thanks again,

Mike Mattix

# March 16, 2007 2:12 PM

Loraine said:

Thanks for this Bertrand, very useful article - problem sorted:-)

# April 5, 2007 3:22 PM

Leo said:

When I use this fix, I get 'Sys' is undefined & also 'Type' is undefined when I run the app with debug="false". Using debug="true" works with no problem.

I am using the latest Ajax release 1.0.

Any suggestions?

# April 25, 2007 11:45 AM

Bertrand Le Roy said:

Leo: you probably introduced a syntax error when you patched the file. Please double check your patched file. You can also look at all error messages, you probably have a syntax error message before the undefined message. That will give you the line number of the syntax error.

# April 25, 2007 1:06 PM

Nathan said:

Did the orcas release fix it?  Have the 'ajax bits' been released yet?

http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx

# April 27, 2007 11:53 PM

Bertrand Le Roy said:

Yes.

# April 28, 2007 12:13 AM

Henry Cordes said:

This only works for <compilation debug="true" /> in web.config.

If I try debug="false" I get the following error:

'Sys' is undefined, 'Type' is undefined.

Can you give me any help?

# May 9, 2007 2:24 AM

Bertrand Le Roy said:

Henry: that indicates a syntax error probably happened before. You probably made a mistake when you patched the release version of the file.

# May 9, 2007 12:54 PM

DEEPAK GUPTA said:

NICE ONE ITS HELPS ME AND MY PROBLEM IS RESOLVED BUT AFTER INCLUDING JS FILE, I START GETTING AN ERROR -- 'SYS IS UNDEFINED'
# May 22, 2007 5:58 AM

Bertrand Le Roy said:

Deepak: no need to shout. That indicates a syntax error. You probably made a mistake when you patched the file.

# May 22, 2007 1:50 PM

Marc Mezzacca said:

Thanks for this patch Bertrand. Is Microsoft going to include this in future releases (hopefully???). A couple notes that were confusing to me: 1) Some people getting the 'Sys' error may point pointing the entire script manager to the directory. They shouldn't... The exact code should look similiar to: 2) For ASP.NET AJAS Toolkit users, they must use this patch and the one for the ASP.NET AJAX Toolkit
# May 30, 2007 3:42 PM

Bertrand Le Roy said:

Marc: the fix is already in the Orcas Beta and will ship with all future versions.

# May 30, 2007 3:55 PM

Yendi said:

Bertrand, First of all, thank you for this article. I'm getting also Sys and Type undefined. I've rechecked my patch and it's fine. I've already patched the AJAX Toolkit also. Could you please look at: www.nortia.com.mx and tell me if you see the error. Any help would be appreciated. THANKS!!
# May 31, 2007 12:44 PM

Yendi said:

Oh, something I forgot.. My locale is ES-MX. Perhaps this is where I'm missing something??

# May 31, 2007 12:48 PM

Bertrand Le Roy said:

Yendi: there doesn't seem to be a site there. Can you check the spelling of the url?

# May 31, 2007 12:52 PM

Yendi said:

# May 31, 2007 1:08 PM

Gann said:

Can you please tell me, i have put this changes in two files in my solution explorer at script manager i have to point this reference to the new file path, how can i give that, it is in my local, but iam deploying at the remote system.
# May 31, 2007 8:33 PM

Atanu said:

Bertrand, thanks for this patch. However you are not clear at one point in the posting above - which is why you are seeing folks leaving comments about getting these errors with debug="false": 'Sys' is undefined, 'Type' is undefined Bertrand writes: Look for "switch(Sys.Browser.agent){case Sys.Browser.InternetExplorer:" and replace everything between that and "case Sys.Browser.Safari:" with the following: ... followed by code Unfortunately in that code he repeats this: switch(Sys.Browser.agent){case Sys.Browser.InternetExplorer: whereas what he probably meant to say was: Look for "switch(Sys.Browser.agent){case Sys.Browser.InternetExplorer:" and replace THAT AND EVERYTHING UPTO "case Sys.Browser.Safari:" In case it isn't obvious, you need to ensure that switch(Sys.Browser.agent){case Sys.Browser.InternetExplorer: is not repeated again - which is what will happen if you follow his directions to the letter. In that case, you will get these errors with debug="false": 'Sys' is undefined, 'Type' is undefined
# May 31, 2007 10:30 PM

Bertrand Le Roy said:

Yendi: thanks for the feedback, there's indeed a problem if you enable localization. See the updated known issues at the end of the post for a workaround.

Gann: I'm sorry, but could you please rephrase your question? I'm not sure I'm following you. Did you deploy the script files on the remote system?

Atanu: thanks for the detective work, I should have seen that one. I updated the post.

# June 1, 2007 12:53 PM

Faisal said:

Hi Bertrand, I have observed a piculiar thing. I did everything you said like copying the System.Web.Extensions folder found into my js folder and then pointing ScriptPath to that folder as inside the .aspx page EXCEPT doing the patch. And I found the error "access is denied" is gone without using the patch! However, there appeared two new erros as Line: 116, Error: 'Sys' is undefined and Line: 211, Error: 'Sys' is undefined Fact is if I implement the patch as you said, the situation remains same. Please help.
# June 4, 2007 3:36 AM

David Miranda said:

Hello, I have sometrouble patching the files. i added the external script files downloaded here in the same foldder of my project, i point ScriptPath of the ScriptManager to "~/scripts/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js", i patched the files as you explained and i get 2 errors of sys is undefined. I restore the original files downloaded and i get the same error. In my config the debug is set to false. Any ideas?
# June 4, 2007 11:23 AM

David Miranda said:

never mind i've found my error, thanks it works great.
# June 4, 2007 12:23 PM

Bertrand Le Roy said:

Faisal, you're not getting the access denied error because it fails before it even reaches it. The error you're getting is probably caused by a syntax error introduced by your incorrectly patching the file. Please double-check.

# June 4, 2007 1:30 PM

SK said:

Hi David, " Hello, I have sometrouble patching the files. i added the external script files downloaded here in the same foldder of my project, i point ScriptPath of the ScriptManager to "~/scripts/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js", i patched the files as you explained and i get 2 errors of sys is undefined. I restore the original files downloaded and i get the same error. In my config the debug is set to false. Any ideas? " i am alos getting same errors. Could you let me know where to fix? Thanks.
# June 5, 2007 2:23 PM

Bertrand Le Roy said:

SK: double-check that you properly patched the files, look at the source code of the page from the browser, check the url of the script tag points to the place where the script files are located.

# June 5, 2007 2:46 PM

SK said:

I made it work by copying all ajaxtoolkit control js files to the same path of script files and renaming them "AjaxControlToolkit.Common.xxxx". This is not elegant but it worked.
# June 5, 2007 3:24 PM

笑煞天 said:

# June 8, 2007 4:27 AM

stefano said:

hi, thank you for your fix. I still have this problem. I have a datagrid with a template column with a small image within. When the user hover it a balloon appears (similar to that of google maps) displaying some data. Before your fix there was no way to show it within a iframe. Thanks to your fix now the balloon displays, but it seem that it ignores offset values, do you have any idea? Stefano
# June 14, 2007 8:55 AM

Bertrand Le Roy said:

No, offset values on what?

# June 14, 2007 1:38 PM

margiex said:

拷贝C:\ProgramFiles\MicrosoftASP.NET\ASP.NET2.0AJAXExtensions\v1.0.61025\目录下的MicrosoftAjaxLibrary...

# June 15, 2007 4:06 AM

stefano said:

Sorry, I missed to say the most important thing!! The balloon is actually a HoverMenuExtender, I was talkin about OffsetX and OffsetY properties of this extender. After your fix now the extender display, but it's centered above the control it extends and the offset values are ignored.
# June 16, 2007 6:38 PM

Bertrand Le Roy said:

Stefano: you should probably ask this question to the toolkit team.

# June 18, 2007 12:20 AM

stefano said:

I will, but I think this problem is releted with this article, since if I see the page outside the iframe the behavior of the extender is perfect. Sorry if I bother you once again!

# June 18, 2007 3:58 AM

Bertrand Le Roy said:

Stefano: it is related to the iframe, but the patch here only deals with the security issue. It may end up being a problem somewhere in Microsoft Ajax, but you should start by asking the toolkit team as this happens with one of their extenders.

# June 18, 2007 4:06 PM

Shane said:

Thanks for this great info. I wanted to pass along a tip I learned while applying this patch. After applying the patch and trying to run the app I was also getting the 'Sys' and 'Type' undefined errors that I saw other people getting. It took a long time to track down, but what I found was that our Sys Admins had deployed a tool called URLScan onto every desktop to prevent users from going to potentially malicious websites. Well, that tool also has a setting that prevents URLs with periods in their address. We figured this out based on using Fiddler and identifying that we were getting a 404 error when trying to load the patched Ajax files. The URLScan tool was preventing us from loading that file. Anyways, I hope that helps someone out there.

# June 21, 2007 10:53 AM

Bertrand Le Roy said:

Shane: urls with periods in the address? That's radical. Most of the web must be filtered out by this?

# June 21, 2007 9:05 PM

Ajaa said:

Hi

I was wondering about one thing.

I added the scriptpath and this is ok.

but why do I need to modify the

MicrosoftAjax.debug.js and MicrosoftAjax.js files?

Why havent this been fixed in the files from the download location?

When I did the abouve I still get an error when trying to use ajaxToolkit. Do you have any idea as to why?

When making these changes do I need to modify any references to the ajaxtoolkit?

Help is appreciated

# June 27, 2007 2:09 PM

Bertrand Le Roy said:

Ajaa: the files in the download location are the exact same files that are embedded in the dll. We're not servicing one and not the other. That's why we're presenting this as a patch for the people who need it until it is integrated into the main build (which it is in the Orcas betas). See this as a way to get the fix earlier.

About the toolkit issues, please read UPDATE 2 in the post. You can also contact the toolkit folks through the CodePlex site or the forums.

# June 27, 2007 2:30 PM

Arnt Henning said:

Hi

Thanks!!! The patch worked great!!

I just wanted to give some tips of problems I had.

When I first tried to

- setting a general ScriptPath on the ScriptManager

this produced the Sys error that people talk about here...

But when I changed this to

<atlas:ScriptManager ID="ScriptManager1" runat="server"  >

<Scripts>

<atlas:ScriptReference

   Name="MicrosoftAjax.js" ScriptMode="Auto"

Path="~/AJAXWA/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js"/>

</Scripts>

</atlas:ScriptManager>

Everything worked great.

It runs with no errors :)

Thanks alot

# June 28, 2007 3:50 AM

Arnt Henning said:

I just wanted to mention another problem I had. Although applying the patch worked I got problems when using the ajaxToolkit (latest release).

I got an error that ajaxToolkit could not be found.

To solve this I added the ajaxToolkit dll's in same folder as

MicrosoftAjax.js and MicrosoftAjax.debug.js

and renamed them to

AjaxControlToolkit.Common.Common.js

AjaxControlToolkit.Common.DateTime.js

AjaxControlToolkit.Common.Input.js

AjaxControlToolkit.Common.Threading.js

(as you can see I added the prefix 'AjaxControlToolkit.Common.')

This is mentioned earlier here but I just thought I can repeat it just in case!

Now everything works for me :) Ive got a updatepanel and the AjaxToolkit Rating control and theire 100% up and running!

Thanks alot for this patch!

# June 28, 2007 4:08 AM

Madia Thomas said:

Why don't you guys just provide us with the modified file?

# July 3, 2007 9:57 AM

Bertrand Le Roy said:

Madia: because this bug doesn't meet the servicing bar. This is fixed in the Orcas beta release, which has been available for a few months now.

# July 3, 2007 4:47 PM

DEEPAK GUPTA said:

Hello Friends

i have added  

   <Scripts>

       <ajax:ScriptReference Name="MicrosoftAjax.js" ScriptMode="Auto" Path="~/Scripts/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js" />

   </Scripts>

inside my ScriptManager and even update the patch for MicrosoftAjax.js and MicrosoftAJAX.debug.js files. But even then am getting JavaScript Error - Sys is undefined..

Please help me.. I am not getting where i am doing wrong.

Any help is greatly appreciated..

Bye

Deepak Gupta

(www.broadwayinfotech.com.au)

# July 4, 2007 10:07 AM

Bertrand Le Roy said:

Deepak: if you look at the generated source from the browser, you can see what address was generated (look for the <script> tag). Adjust your path so that the generated url coincides with where the script really is.

# July 4, 2007 5:12 PM

网际飞狐 said:

# July 11, 2007 2:51 AM

DEEPAK GUPTA said:

Hi Bertran

Thanx for the time..

I have checked the path in the Source code..The path is correct..But still am getting an error "sys is undefined.." Can u tell me some other reason for that..

# July 11, 2007 9:32 AM

Bertrand Le Roy said:

Deepak: well, if the path is correct and you've checked that the file actually gets downloaded (for example using Firebug or Fiddler), you probably introduced a syntax error while patching the file. Does it reproduce in debug and release modes?

# July 11, 2007 1:09 PM

DEEPAK GUPTA said:

Hi Loy

I have checked the path of the Script..

That is correct i think so..I have installed firebug and the path that it shows is...

<script src="/Scripts/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.debug.js" type="text/javascript">

</script>

where Scripts is the Virtual Path Folder of the project...

Now what else should i check...

# July 15, 2007 3:30 AM

DEEPAK GUPTA said:

Hi Loy

I am heartly Sorry to you and Heartly Thanx for the time..

Atlast i got my stupid mistake..Error is resolved..

Actually i have patched the release version file but not debug one..

Thats why i always get an error

Thanx a lot

Thanx once again

Bye

# July 16, 2007 1:37 AM

DEEPAK GUPTA said:

Hi Bertrand Le Roy

I have check in both modes - Release and Debug Mode..The Error "Sys is undefined" comes in both the mode..

Even i have patched my js files 2-3 times but nothing work for me..If you say, Could i send u the patch files by mail...

One more thing i am using FreeTextBox Control(version 3.16) on the same aspx page..Would it be creaitng any problem..

Pls help me..Its really look bad when a popup displays on the Client Screen with the message "Sys is undefined".

Thanx for the help and time in advance..

Bye

# July 16, 2007 6:52 AM

Bertrand Le Roy said:

Deepak: did you check in Firebug that the script do actually get loaded?

# July 16, 2007 1:57 PM

DEEPAK GUPTA said:

Hi Loy

Yes, i check in firebug and the path is correct.

The path that shows is

<script src="/Scripts/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.debug.js" type="text/javascript"></script>

Where Scripts is the folder where all Scripts resides..

Thanx for your time Loy..

I know am annoying you but am not getting at all whats going wrong..

Bye

# July 17, 2007 12:26 AM

Max C said:

I had exactly the same symptoms as Deepak and just fixed it.  If like me you're testing within an iframe then the request to get the script file can be unauthenticated even though you're logged in (because the hosting page's cookies are not accessible to the iframe'ed page).  So if the script files are in a location that requires a logged-in user then you'll be able to download them by manually pasting the URL into the address bar but the iframe'ed page still won't be able to load them.  Just need to change web.config appropriately to fix it.

Having wasted an afternoon on this I just need to let off some steam by saying Microsoft is bonkers beyond belief to leave poor Bertrand helping thousands of developers patching a bug that affects everybody (because every site gets put in an iframe by someone).

Thank you, I feel better now.

# July 17, 2007 2:52 AM

Bertrand Le Roy said:

Deepak: I'm not asking if the path is ok, but if it effectively loads. You can check that in Firebug by expanding the entry in the net tab.

Max: the issue doesn't affect many users as you need to use iframes *and* have your iframe be in a different domain. That is not that common and it is a lot less trouble to offer out of band advice than to release a full service patch. The problem is also fixed in all recent releases of Ajax.

# July 17, 2007 2:10 PM

Matt G said:

If your getting the Sys and Type error. try this:

Set ScriptMode="auto" and in the compliation tag of web.config remove the debug attribute

or change  ScriptMode attribute to ScriptMode="Release".

In debug mode your script tag will alter the path to find a debug js file.

# July 23, 2007 4:02 PM

Bertrand Le Roy said:

Matt: if you followed the post's indication, you should have installed all files from the library, which include both the debug and release versions.

# July 24, 2007 1:40 AM

Ziro said:

Hi.