Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 04, 2011 12:44 PM by Wardy
Mar 09, 2008 07:14 AM|LINK
Sep 21, 2009 04:25 PM|LINK
I had similar problem and I did not give the folder name in the path
and my namespace and assembly name was same just to make my things easy
and it worked with this in the assemblyinfo and same path in while setting the image
<Assembly: System.Web.UI.WebResource("<assembly or namespace>.<image>gif", "image/gif")>
Nov 16, 2009 01:48 PM|LINK
Just my two cents :
For me, it started to work correctly when I stopped using GetType() to get the type to send to GetWebResourceUrl.
When you use GetType() your risk getting a reference to an assembly that is dynamically compiled by ASP.Net and that doesn't contain the resources.
When you use typeof(TypeInTheAssembly) you get a reference to the assembly that you compiled yourself containing the embedded resources.
Mar 11, 2010 09:34 AM|LINK
Check that Buid Action is set to Embedded Resource for the image in Solution Explorer > Properties.
Also, use Project Properties > Resource to add resources, not just add a file to the project.
Mar 12, 2010 07:35 AM|LINK
Step 1) to 3) you got right. Then, the confusion happens, because there are differences in how this is handle in VB vs C#.
The important thing in VB is that the image path is not part of the resource name as it is in C#, so your example would be:
4) In AssemblyInfo.vb:
<Assembly: WebResource("<My Namespace>.test.gif", "image/gif")>
5) In CreateChildControl :
Dim img as new Image
img.ImageUrl = Me.Page.ClientScript.GetWebResourceUrl(Me.GetType(), "<My Namespace>.test.gif")
May 18, 2010 07:20 PM|LINK
I am using C# and the only way I could get this to work was specifying the resource as <NameSpace>.<Folder>.<FileName>.<FileExtension>. For the type parameter, I used the this.GetType()
Note: My structure of the code is as follows:
1. I have a custom control in a separate assembly than the webpage consuming that custom control.
2. My resource is in the same assembly as the custom control and it is the custom control that has the call to the GetWebResourceURL.
Hope this information will be helpful to others.
-Moiz Tankiwala PMP
Nov 04, 2011 12:44 PM|LINK
... this line needs to go in the Assembly properties (Properties folder in the project root / AssemblyInfo.cs)