开发者

How to reference an embedded image from CSS?

This is a NEW question and it is highly related to this topic: How to reference embedded images from CSS? For whatever reason I am forced to post a new thread here, so please see the original thread to understand what the issue is here.

I want to create an asp.net server control which bringt an embedded .CSS field and a few emb开发者_JS百科edded image files. From the css I want to use the background-image command to provide the output HTML using this class with the required images.

I can't get any of the pointed approaches to work.

I tried all variations...:

[assembly: System.Web.UI.WebResource("MapBG.png", "image/png")] 
[assembly: System.Web.UI.WebResource("myWebControls.Resources.MapBG.png", "image/png")]  

background-image: url(<%=WebResource("myWebControls.Resources.MapBG.png")%>);   
background-image: url('<%= Page.ClientScript.GetWebResourceUrl(typeof(myWebControls.ElanStatusMap.ElanStatusMap), "MapBG.png") %>'); 
background-image: url('<%= Page.ClientScript.GetWebResourceUrl(typeof(myWebControls.ElanStatusMap.ElanStatusMap), "myWebControls.Resources.MapBG.png") %>'); 

Nothing works. Any more ideas on this?


CSS pages are not rendered like aspx pages, so you can't put server blocks in them.

Instead, you can include that CSS in your ASPX page in a <style> block and then you can use this mechanism.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜