|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP.NET Embedded ResourcesI have a project where I am required to embed a few images and CSS files in
the assembly (v1.1) and read them out at runtime. I know that this can be done using an HttpHandler/.axd file (like the one used for FreeTextBox http://www.freetextbox.com), but I've never tried this before. Does anyone have any sample code for this? I know they've made this much easier in 2.0. -- Grant Harmeyer This is a code that outputs static image from a array.
It's a regular aspx page and called like this <img src="renewSes.aspx"> You should be able easily modify it to output from resource file George. public class renewSes : System.Web.UI.Page { static byte [] gif = {0x47,0x49,0x46,0x38,0x39,0x61,0x01,0x00,0x01,0x00,0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0xf9,0x04,0x09,0x00,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x08,0x04,0x00,0x01,0x04,0x04,0x00,0x3b,0x00}; override protected void OnInit(EventArgs e) { Response.AddHeader("ContentType", "image/gif"); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(gif); Response.End(); } } Show quote "Grant Harmeyer" <n**@internetapollo.com> wrote in message news:uKxzm7DGGHA.3728@tk2msftngp13.phx.gbl... >I have a project where I am required to embed a few images and CSS files in >the assembly (v1.1) and read them out at runtime. I know that this can be >done using an HttpHandler/.axd file (like the one used for FreeTextBox >http://www.freetextbox.com), but I've never tried this before. Does anyone >have any sample code for this? I know they've made this much easier in 2.0. > > -- > Grant Harmeyer > Yes, but that still doesn't use an HttpHandler to read the image or CSS from
the assembly as an embedded resource. For example, the FreeTextBox WebControl has all of the images and such embedded into the assembly. Then when the page is rendered, the webpage references the images like so: <img src="FtbWebResource.axd?a=FreeTextBox%2c+Version%3d3.1.5000.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d5962a4e684a48b87&r=FreeTextBoxControls.Resources.Images.OfficeMac.superscript.gif&t=632727198542727578" /> I would like to reference the images and CSS files that I use for themes to be referenced in the same way. Show quote "George Ter-Saakov" <gt-***@cardone.com> wrote in message news:e9WKLlGGGHA.344@TK2MSFTNGP11.phx.gbl... > This is a code that outputs static image from a array. > It's a regular aspx page and called like this <img src="renewSes.aspx"> > You should be able easily modify it to output from resource file > > George. > > public class renewSes : System.Web.UI.Page > { > > static byte [] gif = > {0x47,0x49,0x46,0x38,0x39,0x61,0x01,0x00,0x01,0x00,0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0xf9,0x04,0x09,0x00,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x08,0x04,0x00,0x01,0x04,0x04,0x00,0x3b,0x00}; > > override protected void OnInit(EventArgs e) > > { > > Response.AddHeader("ContentType", "image/gif"); > > Response.Cache.SetCacheability(HttpCacheability.NoCache); > > Response.BinaryWrite(gif); > > Response.End(); > > } > > > } > > > > > > > > > "Grant Harmeyer" <n**@internetapollo.com> wrote in message > news:uKxzm7DGGHA.3728@tk2msftngp13.phx.gbl... >>I have a project where I am required to embed a few images and CSS files >>in the assembly (v1.1) and read them out at runtime. I know that this can >>be done using an HttpHandler/.axd file (like the one used for FreeTextBox >>http://www.freetextbox.com), but I've never tried this before. Does anyone >>have any sample code for this? I know they've made this much easier in >>2.0. >> >> -- >> Grant Harmeyer >> > > |
|||||||||||||||||||||||