I have a web control library project and am trying to embed a javascript file and images in the assembly. The .js and .gif files are in subfolder named Resources. I have marked the .js and .gif files as embedded resources added the following lines in the
AssemblyInfo.vb file
This does not work. When I move the .js and .gif file to the project root and obviously remove the Resources reference in the above code it works fine.
I have a Web Control Library project and anytime I try to use a subfolder, say "Javascript" and store embedded resources there they are inaccessible when trying to reach them with the webresource.axd handler. If I store them at the root not problems.
In my experience, if the embedded resources are under a sub-folder, and you have set the build action appropriately, you may need to include the name of the sub-folder in the name of the resource.
For example,
If I have a web application project called MySite with a script sub-folder and my script file is called site.js, I would refer to the file as...
dsa1971
Member
142 Points
144 Posts
subfolders and webresource.axd
Nov 30, 2007 09:09 PM|LINK
I have a web control library project and am trying to embed a javascript file and images in the assembly. The .js and .gif files are in subfolder named Resources. I have marked the .js and .gif files as embedded resources added the following lines in the AssemblyInfo.vb file
<Assembly: System.Web.UI.WebResource("JWebControls.Resources.JWebControlsUtils.js", "text/javascript")> <Assembly: System.Web.UI.WebResource("JWebControls.Resources.calendar.gif", "image/gif")>embedded resource WebResourceAttribute
david wendel...
All-Star
15865 Points
2243 Posts
Re: subfolders and webresource.axd
Dec 02, 2007 02:30 AM|LINK
For each file you want to embed, you have to change its build action to Embedded Resource.
Here's a link to a how-to:
http://aspalliance.com/726
dsa1971
Member
142 Points
144 Posts
Re: subfolders and webresource.axd
Dec 03, 2007 12:55 PM|LINK
The build action is set to Embedded Resource. It's when I try to put them into a subfolder that I encounter a problem.
david wendel...
All-Star
15865 Points
2243 Posts
Re: subfolders and webresource.axd
Dec 03, 2007 05:56 PM|LINK
By subfolders, do you mean the Resources folder, or a sub-folder of the Resources folder?
I ask because I put embeddes stuff in the Resources folder all the time.
dsa1971
Member
142 Points
144 Posts
Re: subfolders and webresource.axd
Dec 03, 2007 08:55 PM|LINK
I have a Web Control Library project and anytime I try to use a subfolder, say "Javascript" and store embedded resources there they are inaccessible when trying to reach them with the webresource.axd handler. If I store them at the root not problems.
killercolt25...
Member
2 Points
2 Posts
Re: subfolders and webresource.axd
Feb 25, 2010 05:46 PM|LINK
In my experience, if the embedded resources are under a sub-folder, and you have set the build action appropriately, you may need to include the name of the sub-folder in the name of the resource.
For example,
If I have a web application project called MySite with a script sub-folder and my script file is called site.js, I would refer to the file as...
MySite.Script.site.js
Cheers,
KC