In a library I am building for my asp.net, is it possible to embed a javascript file as an embedded resource and still be able to retrieve it via a URL call and/or script tag without creating a secondary ashx just to load the javascript?
Just add the script tags in the master page or content page and the javascripts can be included in them. If you want to add a JavaScript file to them, you can use src attribute in the script tag.
To embed a client script file in an assembly. In Visual Studio, create a new class library project named SampleControl. Add references to the System. Web, System.
The recommended approach is to put in a separate JavaScript file or inside a section defined in Layout page. A section can be added in the MVC Layout page using @RenderSection() directive. For example, we can define a section in Layout page under <head> tag for scripts like below.
ASP.NET requires the use of the client-side Javascript, as that's how ASP.NET handles its Events via PostBacks.
It's entirely possible.
A quick google came up with this really good tutorial Managing Your JavaScript Library in ASP.NET
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With