(I think this is going to take a wiz to understand, but please give it a try; 10 points to the expert!!)
Background: I have an ASP.NET AJAX web app that can be launched from our external Sharepoint portal accessable to employees of our company via the internet. Traditionally, when the site is run from inside the company the url to the default page is as follows:
http://MyASPNetApp/Pages/Default.aspx
...when accessed via the SharePoint portal, the site is passed as a query string from the main portal's site address as follows:
https://www.ourcompanyportal.com/Pages/,DanaInfo=MyASPNetApp+Default.aspx
The 'DanaInfo=' is added everywhere including if veiwing the source on a page that includes AJAX. Traditionally, the script reference in the page's source would be as follows:
script src="/ScriptResource.axd?d=-tCmVI5qDJ3yI-BH1oZD2Xgv_m6oCh7y6d3mVAu8Ih2bYq0LoRRLRi2zKYMtHvVX9FMzUcK6-j2wNZMFGbKeNCposW6tctq5yr3dOBAqDwc1&t=ffffffffd2c7995f" mce_src="/ScriptResource.axd?d=-tCmVI5qDJ3yI-BH1oZD2Xgv_m6oCh7y6d3mVAu8Ih2bYq0LoRRLRi2zKYMtHvVX9FMzUcK6-j2wNZMFGbKeNCposW6tctq5yr3dOBAqDwc1&t=ffffffffd2c7995f" type="text/javascript"
This same source pulled up via the site that was pulled up through our Sharepoint portal is as follows:
script src="/,DanaInfo=MyASPNetApp,CT=js+ScriptResource.axd?d=DG6RXWoKNh76Nda17-e1arV9TyMEFuIfMEy7nnLdGGR464jQbDCnNP3yjAnping2mXRm3ra2cVBIEsNGLPMm9G3TcJvZnbX5QwHEdeHrzEs1&t=ffffffffd2c7995f" mce_src="/,DanaInfo=MyASPNetApp,CT=js+ScriptResource.axd?d=DG6RXWoKNh76Nda17-e1arV9TyMEFuIfMEy7nnLdGGR464jQbDCnNP3yjAnping2mXRm3ra2cVBIEsNGLPMm9G3TcJvZnbX5QwHEdeHrzEs1&t=ffffffffd2c7995f" type="text/javascript"
Notice in order for the site pulled up via SharePoint the 'DanaInfo' is appended on to everyhting so the proper location can be resolved. This method works about 99% of the time; it is not a manual process just something Sharepoint automatically does.
However, I found today that if I have an ASP.NET page that contains AJAX in a hidden control (say a grid) that is not initially visible, and then made visible by a user action (button click, whatever), then the additional AJAX scripts are dynamically loaded at that time when the control becomes visible.
This is actually pretty efficient and I like it. The problem is that the dynamically loaded AJAX scripts from the newly visable control DO NOT have the appropriate 'DanaInfo' preappnded modifiers added to them and a JavaScript error is thrown as follows:
Error: Sys.ScriptLoadFailedException: The script ‘/ScriptResource.axd?d=Cfo4m…………could not be loaded.
I am able to verify that the scripts are dynamically loaded after the page loads in the 'Solution Explorer' window in VS.NET 2008 while debugging. (Note: In IE the checkbox for "Disable Script Debugging - Internet Explorer" must be unchecked to see the 'Script Documents' node in VS.NET's Solution Explorer). While debugging I can see the many AJAX scripts being loded under the 'Script Documents' node in the Solution Explorer as I navigate to pages. Upon making the control visible on my page, I can see additional AJAX scripts loaded for the AJAX controls that were previously hidden.
So there it is. Those dynamically loaded AJAX scripts for the newly visible control containing AJAX is causing my site to throw an JavaScript error because it can not load the script because it does not know where it is. Again, this is not a problem when just ran through the traditional site link; it has to do with being pulled up via the Sharepoint portal.
Does anyone know a way around this issue? Is there any way maybe serverside to force loading ALL of the AJAX scripts needed, even for controls that are hidden upon Page_Load? I think if something like this is possible then it may solve this problem, or if there are any other solutions please speak up!!
