views:

112

answers:

0

We have a Visual Studio 2010 solution with several C# web applications (not web sites) and a bunch of common files (css, javascript and plain images) that were previously simply shared through Visual SourceSafe 2005; wanting to cut all these sharings (we may migrate to TFS 2010 in the not-so-near future) I am trying to embed all these files in a common library that all these projects reference and call them as WebResources.

I managed to do that with relatively few complications, but the problem came in when I needed to reference an embedded image in a css that is not embedded to set it as background image for a div tag, since the <% = WebResource(...)%> method doesn't seem to work. I figured I'd set the attribute programmatically with a line like

divBody.Style["background-image"] = Page.ClientScript.GetWebResourceUrl(...)

in the Page_Load, but either the tag doesn't have the runat=server attribute, so I cannot access it from code-behind, or I add the attribute so the line above compiles, but then for some reason the image won't show up. I know this would get me to the solution, since if I try to write manually the WebResource.axd?... url that would result from the aforementioned method url in the css the image appears.

All in all, the question is: do you know a better way to point to embedded resources from non-embedded files? Or if there's no other work-around, how can I make this work (ie why doesn't the image show up?)? Thank you.