Reputation: 21013
I have embedded a javascript library, some CSS and some images into a class library as embedded resources.
I have created custom controls to access both the javascript and the CSS, but within the CSS, there are certain parts that use background images that are referenced via url(../../img/img.png)
. How would i handle these requests?
P.S. i have already thought about writing a IHttpHandler
to capture and redirect these requests, but i would rather not have to edit web.config further to achieve this.
Upvotes: 0
Views: 1046
Reputation: 39916
Duplicate: How to reference embedded images from CSS?
<% = WebResource("image1.jpg") %>
You can use above statement inside your CSS file, and while you register your CSS with WebResourceAttribute, you can set "PerformSubstitution" to true
Default.css
body{
background: <%=WebResource("xyz.jpg")%>
}
[assembly, WebResource("Default.css","text/css", PerformSubstitution=true)]
[assembly, WebResource("xyz.jpg","image/jpg")]
Upvotes: 1
Reputation: 99
If it's not too big an image and target browsers are acceptable, you could use a Data URI...
http://websemantics.co.uk/online_tools/image_to_data_uri_convertor/
Upvotes: 0