embedded resource

Discussion in 'ASP .Net' started by Andreas Zita, Jan 6, 2006.

  1. Andreas Zita

    Andreas Zita Guest

    Hi

    Im creating my first 2.0 site and I cant find the Build Action property? I
    want to embedd an image-file in my site-assembly but I don't know how? In
    1.1 I could set Build Action to Embedded Resource in the properties pane but
    this doesn't seem to be available any more???

    /Andreas
    Andreas Zita, Jan 6, 2006
    #1
    1. Advertising

  2. Andreas Zita

    Teemu Keiski Guest

    Hi,

    ASP.NET does not build assemblies with resources exaclty similarly as it did
    in ASP.NET 1.1 (unless you start to use web application projects see
    http://webproject.scottgu.com)

    Now, you'd add a resource file to App_GlobalResources directory (special
    directory for ASP.NET 2.0) and add the image as a resource to that resource
    file.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    "Andreas Zita" <> wrote in message
    news:%...
    > Hi
    >
    > Im creating my first 2.0 site and I cant find the Build Action property? I
    > want to embedd an image-file in my site-assembly but I don't know how? In
    > 1.1 I could set Build Action to Embedded Resource in the properties pane
    > but this doesn't seem to be available any more???
    >
    > /Andreas
    >
    Teemu Keiski, Jan 6, 2006
    #2
    1. Advertising

  3. Andreas Zita

    Andreas Zita Guest

    Aha I see... interresting. Previously I used to embedd layout images/icons
    and retrieve them with a custom aspx-request and a resource-id such as:
    ..../GetResource.aspx?id=HeaderBackground. Im building my html-pages with XSL
    (HTMLWriter to Response.Output) so I need URL:s to my resources. Is there a
    similar built in method to retrieve resources that have been embedded in a
    resx-file in 2.0?

    /Andreas

    > ASP.NET does not build assemblies with resources exaclty similarly as it
    > did in ASP.NET 1.1 (unless you start to use web application projects see
    > http://webproject.scottgu.com)
    >
    > Now, you'd add a resource file to App_GlobalResources directory (special
    > directory for ASP.NET 2.0) and add the image as a resource to that
    > resource file.
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    Andreas Zita, Jan 6, 2006
    #3
  4. I don't know what you mean but:

    1) Create the folder as suggested.
    2) Add a textfile like text1.txt (for testing)
    3) Add the resource.resx
    4) The pane is shown, drag the text1.text on this resource pane.
    5) You should see a pretty large image with title.
    6) In your source use: ... resources.resource.text1.tostring

    That's it.




    "Andreas Zita" <> schreef in bericht
    news:OW$nv%...
    > Aha I see... interresting. Previously I used to embedd layout images/icons
    > and retrieve them with a custom aspx-request and a resource-id such as:
    > .../GetResource.aspx?id=HeaderBackground. Im building my html-pages with
    > XSL (HTMLWriter to Response.Output) so I need URL:s to my resources. Is
    > there a similar built in method to retrieve resources that have been
    > embedded in a resx-file in 2.0?
    >
    > /Andreas
    >
    >> ASP.NET does not build assemblies with resources exaclty similarly as it
    >> did in ASP.NET 1.1 (unless you start to use web application projects see
    >> http://webproject.scottgu.com)
    >>
    >> Now, you'd add a resource file to App_GlobalResources directory (special
    >> directory for ASP.NET 2.0) and add the image as a resource to that
    >> resource file.
    >>
    >> --
    >> Teemu Keiski
    >> ASP.NET MVP, AspInsider
    >> Finland, EU
    >> http://blogs.aspadvice.com/joteke

    >
    >
    Edwin Knoppert, Jan 6, 2006
    #4
  5. Andreas Zita

    Andreas Zita Guest

    Okey ... Anyhow ... Is this right?: xsl-files in App_GlobalResources always
    embeds but in App_LocalResource they don't?
    And ... how do I retrieve an embedded Stylesheet from App_GlobalResources ?

    Thanks for your help! :)

    /Andreas

    "Edwin Knoppert" <> skrev i meddelandet
    news:43be721d$0$10082$...
    >I don't know what you mean but:
    >
    > 1) Create the folder as suggested.
    > 2) Add a textfile like text1.txt (for testing)
    > 3) Add the resource.resx
    > 4) The pane is shown, drag the text1.text on this resource pane.
    > 5) You should see a pretty large image with title.
    > 6) In your source use: ... resources.resource.text1.tostring
    >
    > That's it.
    Andreas Zita, Jan 6, 2006
    #5
  6. Andreas Zita

    Teemu Keiski Guest

    Hi,

    sure, these are called web resources and you can generate the call needed to
    fetch them.

    Here's link to tutorial:
    http://www.asp.net/QuickStart/aspnet/doc/extensibility.aspx#WR

    But basically, you specify it to be a web resource with WebResource
    attribute and access it with Page.ClientScript.GetWebResourceUrl () call.

    And here's a good article on the subject
    http://aspalliance.com/726

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    "Andreas Zita" <> wrote in message
    news:OW$nv%...
    > Aha I see... interresting. Previously I used to embedd layout images/icons
    > and retrieve them with a custom aspx-request and a resource-id such as:
    > .../GetResource.aspx?id=HeaderBackground. Im building my html-pages with
    > XSL (HTMLWriter to Response.Output) so I need URL:s to my resources. Is
    > there a similar built in method to retrieve resources that have been
    > embedded in a resx-file in 2.0?
    >
    > /Andreas
    >
    >> ASP.NET does not build assemblies with resources exaclty similarly as it
    >> did in ASP.NET 1.1 (unless you start to use web application projects see
    >> http://webproject.scottgu.com)
    >>
    >> Now, you'd add a resource file to App_GlobalResources directory (special
    >> directory for ASP.NET 2.0) and add the image as a resource to that
    >> resource file.
    >>
    >> --
    >> Teemu Keiski
    >> ASP.NET MVP, AspInsider
    >> Finland, EU
    >> http://blogs.aspadvice.com/joteke

    >
    >
    Teemu Keiski, Jan 6, 2006
    #6
  7. Andreas Zita

    Andreas Zita Guest

    Hi and thanks for replying ... but I still dont understand... for instance
    in the second url they where pointing to the Build Action property which
    isnt available anymore (?) ...

    I am aware of that it isnt easy to understand what my problem really is... i
    dont know for sure myself ... anyhow ... This is what I have come up with:

    I have placed all my image-files in the App_GlobalResources-folder and added
    them to a Images.resx file in the same folder. Then I created a aspx-file
    for retrieving these images as the code below shows. Is this approach sane?
    or is there some other more common method I have missed?

    public partial class ASP_GetResource : System.Web.UI.Pag
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    System.Drawing.Bitmap image = GetGlobalResourceObject("Images",
    ResourceKey) as System.Drawing.Bitmap;
    Response.ContentType = "image/gif";
    image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
    image.Dispose();
    }

    string ResourceKey { get { return Request.QueryString["res"]; }}
    }

    /Andreas

    > Hi,
    >
    > sure, these are called web resources and you can generate the call needed
    > to fetch them.
    >
    > Here's link to tutorial:
    > http://www.asp.net/QuickStart/aspnet/doc/extensibility.aspx#WR
    >
    > But basically, you specify it to be a web resource with WebResource
    > attribute and access it with Page.ClientScript.GetWebResourceUrl () call.
    >
    > And here's a good article on the subject
    > http://aspalliance.com/726
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    Andreas Zita, Jan 6, 2006
    #7
  8. Andreas Zita

    Teemu Keiski Guest

    > in the second url they where pointing to the Build Action property which
    > isnt available anymore (?) ...


    It is, if you built components into external class library. Writing a class
    library is still there (though not with VWD express).That example just point
    to such.

    > I am aware of that it isnt easy to understand what my problem really is...
    > i dont know for sure myself ... anyhow ... This is what I have come up
    > with:
    >
    > I have placed all my image-files in the App_GlobalResources-folder and
    > added them to a Images.resx file in the same folder. Then I created a
    > aspx-file for retrieving these images as the code below shows. Is this
    > approach sane? or is there some other more common method I have missed?
    >


    That works fine. There's also the Web resource mechanism, in which Page
    framework provides you the URl to the resource automatically, e-g
    autogenerates it so that resource is served from resource files on the fly.

    For example you'd just give:

    Image1.ImageUrl =
    Page.ClientScript.GetWebResourceUrl(this.GetType(),"myimage.gif")

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke
    Teemu Keiski, Jan 6, 2006
    #8
  9. Andreas Zita

    Teemu Keiski Guest

    Just to add that web resource scenario would require the external class
    library.

    Teemu

    "Teemu Keiski" <> wrote in message
    news:...
    >> in the second url they where pointing to the Build Action property which
    >> isnt available anymore (?) ...

    >
    > It is, if you built components into external class library. Writing a
    > class library is still there (though not with VWD express).That example
    > just point to such.
    >
    >> I am aware of that it isnt easy to understand what my problem really
    >> is... i dont know for sure myself ... anyhow ... This is what I have come
    >> up with:
    >>
    >> I have placed all my image-files in the App_GlobalResources-folder and
    >> added them to a Images.resx file in the same folder. Then I created a
    >> aspx-file for retrieving these images as the code below shows. Is this
    >> approach sane? or is there some other more common method I have missed?
    >>

    >
    > That works fine. There's also the Web resource mechanism, in which Page
    > framework provides you the URl to the resource automatically, e-g
    > autogenerates it so that resource is served from resource files on the
    > fly.
    >
    > For example you'd just give:
    >
    > Image1.ImageUrl =
    > Page.ClientScript.GetWebResourceUrl(this.GetType(),"myimage.gif")
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    >
    Teemu Keiski, Jan 6, 2006
    #9
    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. LidorP
    Replies:
    1
    Views:
    2,132
    Scott M.
    Nov 22, 2003
  2. Johann Blake
    Replies:
    0
    Views:
    483
    Johann Blake
    Dec 17, 2003
  3. Dirc Khan-Evans
    Replies:
    1
    Views:
    895
    Karl Seguin
    Oct 17, 2005
  4. avishosh
    Replies:
    2
    Views:
    10,571
    avishosh
    Aug 8, 2004
  5. Heinrich Moser
    Replies:
    1
    Views:
    458
    Heinrich Moser
    Mar 27, 2008
Loading...

Share This Page