Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We have a server controls library that contains some images that are reused across a number of other web projects.</p> <p>The approach we took was to mark the each images build action as Embedded Resource. Then in the AssemblyInfo file we have lines like the following:</p> <pre><code>[assembly: WebResource("AssemblyName.SubDirectory.ImageName.png", "image/png")] </code></pre> <p>Where AssemblyName is the actual project name, the SubDirectory is the directory in the project the image(s) are located in, etc.</p> <p>This project also emits CSS files; which are also Embedded Resources. The CSS files refer to these images using:</p> <pre><code>.someImage { height: 85px; background-image: url(&lt;%=WebResource("AssemblyName.SubDirectory.Image.png") %&gt;); background-repeat: repeat-x; margin: 0px; padding: 0px; } </code></pre> <p>In the class code, we'll refer to those css files like:</p> <pre><code>HtmlLink cssLink = new HtmlLink(); cssLink.Href = Page.ClientScript.GetWebResourceUrl(this.GetType(), "AssemblyName.css.SomeCssFile.css"); cssLink.Attributes.Add("rel", "stylesheet"); cssLink.Attributes.Add("type", "text/css"); </code></pre> <p>We could just as easily refer to the images directly using something like the above.</p> <p>At this point the assembly is 100% portable. All of the CSS files and required images are embedded into it so you don't have to worry if the calling application has those same images at all. </p> <p>Incidentally, this is how a number of control vendors do things; at least the <a href="http://www.telerik.com" rel="nofollow">better ones</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload