ASP.NET Embedded Resources

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Grant Harmeyer

    ASP.NET Embedded Resources

    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

    #2
    Re: ASP.NET Embedded Resources

    This is a code that outputs static image from a array.
    It's a regular aspx page and called like this <img src="renewSes.a spx">
    You should be able easily modify it to output from resource file

    George.

    public class renewSes : System.Web.UI.P age
    {

    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(EventArg s e)

    {

    Response.AddHea der("ContentTyp e", "image/gif");

    Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);

    Response.Binary Write(gif);

    Response.End();

    }


    }








    "Grant Harmeyer" <net@internetap ollo.com> wrote in message
    news:uKxzm7DGGH A.3728@tk2msftn gp13.phx.gbl...[color=blue]
    >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
    >[/color]


    Comment

    • Grant Harmeyer

      #3
      Re: ASP.NET Embedded Resources

      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="FtbWebReso urce.axd?a=Free TextBox%2c+Vers ion%3d3.1.5000. 0%2c+Culture%3d neutral%2c+Publ icKeyToken%3d59 62a4e684a48b87& r=FreeTextBoxCo ntrols.Resource s.Images.Office Mac.superscript .gif&t=63272719 8542727578"
      />

      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" <gt-nsp@cardone.com > wrote in message
      news:e9WKLlGGGH A.344@TK2MSFTNG P11.phx.gbl...[color=blue]
      > This is a code that outputs static image from a array.
      > It's a regular aspx page and called like this <img src="renewSes.a spx">
      > You should be able easily modify it to output from resource file
      >
      > George.
      >
      > public class renewSes : System.Web.UI.P age
      > {
      >
      > 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(EventArg s e)
      >
      > {
      >
      > Response.AddHea der("ContentTyp e", "image/gif");
      >
      > Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);
      >
      > Response.Binary Write(gif);
      >
      > Response.End();
      >
      > }
      >
      >
      > }
      >
      >
      >
      >
      >
      >
      >
      >
      > "Grant Harmeyer" <net@internetap ollo.com> wrote in message
      > news:uKxzm7DGGH A.3728@tk2msftn gp13.phx.gbl...[color=green]
      >>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
      >>[/color]
      >
      >[/color]


      Comment

      Working...