Last post Feb 21, 2014 04:37 AM by Happy Chen - MSFT
Feb 14, 2014 11:20 AM|ddelella|LINK
should not load the same resources multiple times as long as the ID is the same. I test the control library with 1, 2 and 3 Date controls on the same page, it worked fine. I test a page with just the Spinner control, it worked fine. As soon as I placed
a Date and Spinner on the same page it no longer seems to recognize the TimePicker plug-in resource as being registered. I verified that the order in which the controls appear on the page matters. The page only seems to be registering the resources for the
last control on the page. Here is how I am loading the scripts in each control's OnInit method:
ScriptManager.RegisterClientScriptResource(MyWebpage, MyControlType, ResourceName)
I have checked the IE and Chrome debugging tools and verified that the ScriptResource.axd is no longer registered for the TimePicker plug-in despite putting a break point on that line of code and verifying that it was executed. Can anyone explain why the
RegisterClientScriptResource method appears to only load the resources from the last control on the page?
NOTE: Changing to Page.ClientScript.RegisterClientScriptResource does not change the outcome.
Feb 17, 2014 12:34 AM|Happy Chen - MSFT|LINK
The calling semantics are pretty much the same as the previous calls to WebResource.axd, the only difference is that we are passing in
this instance of the control that wants to register the script. The effect of calling this method results in scripts being loaded from
Please check out the link for details:
Understanding ScriptResource and WebResource in ASP.NET
i would suggest you try implementing your own ScriptManger and then adding the embedded file from there. Here's an example:
public class MyScriptManager : System.Web.UI.ScriptManager
protected override void OnInit(EventArgs e)
RegisterClientScriptResource(this, typeof(ScriptManagerExtension), "MyNamespace.MyScriptFile.js");
Hope it helps you.
Feb 17, 2014 08:17 AM|ddelella|LINK
I understand the difference between WebResource and ScriptResource. I want the files to be loaded as ScriptResources, which they are.
The problem is that for the two controls on the page, we will call them A and B for this example:
1. Control A needs jQuery, jQueryUI, jQuery migrate and a timepicker plug-in.
2. Control B only needs the 3 jQuery scripts.
3. If control A appears on the page by itself, everything works fine.
4. If control B appears on the page by itself everything works fine.
5. If B appears before A on the page everything works fine.
6. ** However, when A appears before B the page seems to forget that it loaded the timepicker plug-in. The page seems to be loading ScriptResources from A and when B goes to load it clears all the loaded resources and loads just B, essentially "losing"
the ScriptResources from control A.
I am trying to understand why it does not retain the ScriptResource.axd loaded from control A?
Feb 18, 2014 09:08 PM|Happy Chen - MSFT|LINK
Normally these files are associated with an httphandler and you can find them in the web.config and you can remove them from their:
<remove path="ScriptResource.axd" verb="GET"/>
This articles below may give you additional details:
ASP.NET Ajax - Script Combining and moving ScriptResource.axd's to Static Scripts
Combining Client Scripts into a Composite Script
Feb 19, 2014 01:32 PM|ddelella|LINK
The links provided good information about the CompositeScriptReference. However, the issue I described is related to a server control library and not within a specific web project. All the information in those pages directly manipulates the ScriptManager.
I am more focused on the proper way to embed and load scripts from a server control library. It just occurred to me that the AJAX Control Toolkit does exactly what I am looking for by embedding jQuery into their library. I will check out their source code
and see if I can find how they are loading their resources.
Feb 21, 2014 04:37 AM|Happy Chen - MSFT|LINK
I will check out their source code and see if I can find how they are loading their resources.
This sounds like a
good idea, I hope you can find