How To: Embed JS and CSS Resources

Skip Navigation LinksIrocon > Blog > 2008 > February, 2008 > February 15, 2008 > How To: Embed JS and CSS Resources

How To: Embed JS and CSS Resources

One of the greatest difficulties when developing common web controls (either server or user controls) that we’ve come across in our development group is how to deal with client-side scripts and images. In ASP.NET 20 you can just embed your resources in the appropriate assemblies and reference them without having to worry about configuration or deployment issues.

To make the JS/CSS file or image accessible from your server control’s assembly, simply add the file to your project, go to the Properties pane, and set the Build Action to Embedded Resource.  To expose the file to a web request, you need to add code  to your AssemblyInfo.cs file.

reference: http://aspalliance.com/726
reference: http://weblogs.asp.net/dwahlin/archive/2007/04/29/creating-custom-asp-net-server-controls-with-embedded-javascript.aspx


Notes:

Kept failing. Error 404

Used:  "application/x-javascript" in AssemblyInfo.vb

Used: scriptManager.RegisterClientScriptResource(pageObj.GetType(), resourceName)

pageObj must reside in the same assembly

Last Updated:Thursday, September 02, 2010By:alferoSource#

Would you like to comment?

Sign in with your OpenID. If you do not know what OpenID is, find out.