ASP.NET Embedded Resources

Discussion in 'ASP .Net' started by Grant Harmeyer, Jan 13, 2006.

  1. 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
     
    Grant Harmeyer, Jan 13, 2006
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    >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
    >
     
    George Ter-Saakov, Jan 13, 2006
    #2
    1. Advertising

  3. 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.


    "George Ter-Saakov" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >>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
    >>

    >
    >
     
    Grant Harmeyer, Jan 13, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vanessa
    Replies:
    1
    Views:
    605
    Jan Hyde
    Aug 4, 2005
  2. Johann Blake
    Replies:
    0
    Views:
    496
    Johann Blake
    Dec 17, 2003
  3. =?Utf-8?B?UG9udGlNYXg=?=

    Using images as embedded resources

    =?Utf-8?B?UG9udGlNYXg=?=, Feb 3, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    315
    =?Utf-8?B?UG9udGlNYXg=?=
    Feb 3, 2005
  4. thomson

    Reading Embedded Resources

    thomson, Oct 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,004
    Karl Seguin
    Oct 27, 2005
  5. Russell E. Owen
    Replies:
    0
    Views:
    727
    Russell E. Owen
    Sep 8, 2006
Loading...

Share This Page