locked
subfolders and webresource.axd RRS feed

  • Question

  • User-1136967153 posted

    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")> 
    and in code I am referencing the .js file as 
     
    Page.ClientScript.RegisterClientScriptInclude("JUtils", _
                     Page.ClientScript.GetWebResourceUrl(Me.GetType(), _
                                                 "JWebControls.Resources.JWebControlsUtils.js"))
     
    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.  
    Any ideas why the subfolder is not working?
      
    
     
    Friday, November 30, 2007 5:09 PM

All replies

  • User1187105292 posted

    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
     

    Saturday, December 1, 2007 10:30 PM
  • User-1136967153 posted

    The build action is set to Embedded Resource.  It's when I try to put them into a subfolder that I encounter a problem.

    Monday, December 3, 2007 8:55 AM
  • User1187105292 posted

    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. 

    Monday, December 3, 2007 1:56 PM
  • User-1136967153 posted

    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.

    Monday, December 3, 2007 4:55 PM
  • User1758855921 posted

    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

    Thursday, February 25, 2010 1:46 PM