WebResource with ASPNET beta 2

F

Frédéric Mayot

Hi,

I'm trying to use web resources in ASP.NET 2.0. Unfortunately, it doesn't
seem to work for me.
Here are the steps I followed :
- Create a project WebSite
- Add a class library project to the solution
- Add the image "toto.gif" at the root of the class library
- Add to the AssemblyInfo.cs of the class library :
using System.Web.UI;

[assembly: WebResourceAttribute("toto.gif", "image/gif")]

- Add a class Class1 to the library (source at the end of the message)
- Use the control Class1 in the Default.aspx page

The control executes the code. The problem is that the image is not shown in
the navigator. The produced code is

<img
src="/WebSite7/WebResource.axd?d=IendFDRRH5UyJK83i7WG_yywijXHGsKhpzfqSIcgeGSWQKAj8LPTV0GZwrlZb6eH0&amp;t=632486131940000000"
style="border-width:0px;" />

The thing is that I can't know if the image is well included when the
library is compiled. Is it normal that the compiler doesn't say anything if
I put a wrong path in the first argument of WebResourceAttribute ?

Any idea ?

Thanks,

Fred



namespace ClassLibrary1

{

public class Class1 : WebControl

{

public Image img;

protected override void CreateChildControls()

{

img = new Image();

Controls.Add(img);

}

protected override void Render(System.Web.UI.HtmlTextWriter writer)

{

img.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof(string),
"toto.gif");

base.Render(writer);

}

}

}
 
B

Brock Allen

You should make sure to change the propery on the GIF file in VS.NET from
"content" to "embedded resource"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top