If you’re creating a custom client-side control by deriving from System.Web.UI.IScriptControl, you may want to embed the .js files into your assembly instead of having to deploy them to every web site that uses those controls (this is especially valuable if you’re developing a control library). All you need to do is to:
[assembly: System.Web.UI.WebResource("ControlLibrary.MyControl.js", "text/javascript")]
public IEnumerable<ScriptReference> GetScriptReferences(){ return new ScriptReference[] { new ScriptReference("ControlLibrary.MyControl.js", "ControlLibrary") };}
However, if you place your JavaScript files in a subfolder (e.g. \ControlLibrary\Scripts\MyControl.js), then you will have to add the folder name to the dotted resource name above, e.g. ControlLibrary.Scripts.MyControl.js.
If you don’t add the folder name, you’ll probably see a run-time error message like this:
System.InvalidOperationException: Assembly ControlLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' contains a Web resource with name 'ControlLibrary.MyControl.js', but does not contain an embedded resource with name 'ControlLibrary.MyControl.js'.