|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
embedded resourceHi
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 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. Show quoteHide quote "Andreas Zita" <andreas.z***@gmail.com> wrote in message news:%231z3oJrEGHA.2196@TK2MSFTNGP10.phx.gbl... > 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 > 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 Show quoteHide quote > 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 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. Show quoteHide quote "Andreas Zita" <andreas.z***@gmail.com> schreef in bericht news:OW$nv%23rEGHA.272@TK2MSFTNGP10.phx.gbl... > 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 > > 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 Show quoteHide quote "Edwin Knoppert" <n***@hellobasic.com> skrev i meddelandet news:43be721d$0$10082$ba620dc5@text.nova.planet.nl... >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. 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 Show quoteHide quote "Andreas Zita" <andreas.z***@gmail.com> wrote in message news:OW$nv%23rEGHA.272@TK2MSFTNGP10.phx.gbl... > 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 > > 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 Show quoteHide quote > 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 > in the second url they where pointing to the Build Action property which It is, if you built components into external class library. Writing a class > isnt available anymore (?) ... 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... That works fine. There's also the Web resource mechanism, in which Page > 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? > 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") Just to add that web resource scenario would require the external class
library. Teemu Show quoteHide quote "Teemu Keiski" <jot***@aspalliance.com> wrote in message news:eHTxbhvEGHA.1464@TK2MSFTNGP11.phx.gbl... >> 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 > >
Other interesting topics
Object Expected error
Function from aspx WebResource.axd request causing errors 2.0 Custom Membership Provider! ASP.NET process identity does not have read permissions to the global assembly cache Help with inline code? Query Data via SMS Custom IIdentity w/ FormsAuthentication Video in ASPX Simple code change deploy in 2.0 |
|||||||||||||||||||||||