Last post Aug 17, 2011 04:10 PM by sacparker
Dec 02, 2008 12:46 PM|volnay|LINK
is it possbile to write this in a embedded extended behavior js file:
var imgPath = '<%=WebResource("fr.MyAsembly.Ajax.panel.gif")%>';
i know it's working in a css embedded file and this synthax is also use in the SliderBehavior.js file in the ajaxtoolkit. But they seem to do something special in the assemblyInfo for this synthax to work.
Anyone has an idea please or at least a suggestion to handle this another way?
thanks in advance.
Dec 08, 2008 04:08 AM|Nai-Dong Jin - MSFT|LINK
From your description, you have embedded images into your control project, right?
You may follow the steps below:
1. Add the image to your project.
2. In the solution explorer, click the file, and in the property window, change build action to "embedded resource."
[assembly: WebResourceAttribute("MyNameSpaces.Resources.MyImage.gif", "image/gif")]
Besides, if you want to use the <%=WebResource…%> expression in a single js file, I think it won’t work. What I suggest is to use GetWebResourceUrl to retrieve
the resource path.
4. In your control rendering code, you'll need the following to produce a usable URL for the image:
Notice I used the same naming convention here.
Dec 08, 2008 07:32 AM|volnay|LINK
Hi and thanks a lot for your response.
My question was not really about how to declare embedded resources for a control which I already know but more precisely how to use <%=WebResource…%> in a control embedded js file. I
would like to set the src attributes of an image in the js file.
What I don’t understand is why is this working in a css file and not in a js? And besides guys that developed the ajaxtoolkit SliderBehavior js file use this synthax !
But your answer gave me an idea of trying to set a property that returns the GetWebResourceUrl and expose it in the behavior js file.
Anyway thanks again for your help
Aug 17, 2011 04:10 PM|sacparker|LINK
This property is new in the .NET Framework version 2.0 and this post is older but... Setting PerformSubstitution to true for the JS file in the AssemblyInfo will work:
PerformSubstitution = true)]