To embed the .js file into our DLL you simply need to select the file in Visual Studio and in the ‘Properties’ window there is a option for ‘Build Action’ set it to ‘Embedded Resource’. This will cause the file to be embedded into the DLL the next time the project is built.
Next you need a way to pull that resource out at run time for inclusion in the response to the client. To do this you first need to add a reference to that resource in your ‘AssemblyInfo.cs’ file with is located in the ‘Properties’ folder in the project. Simply go to the bottom of that file and add a WebResource entry as seen below.
[assembly: System.Web.UI.WebResource("GraphicNetDesign.ServerControls.Web.Utilities.KeepAlive.js", "text/js")]
You will notice that the entire path (namespace) to the file needs to be specified. This will be the path you pass in when attempting to access the resource from your code. So now in your code you just do the following to pull the .js file and register it for client use.