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?
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:
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.
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:
volnay
Member
12 Points
8 Posts
embedded gif webresource in a js behavior file
Dec 02, 2008 12:46 PM|LINK
Hi everybody,
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.
AJAX WebResource AjaxControlToolkit
Nai-Dong Jin...
All-Star
41630 Points
3558 Posts
Re: embedded gif webresource in a js behavior file
Dec 08, 2008 04:08 AM|LINK
Hi,
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."
3. Add the following to your AssemblyInfo.cs file:[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:
Page.ClientScript.GetWebResourceUrl(typeof(MyNameSpaces.MyControl), "MyNameSpaces.Resources.MyImage.gif")Notice I used the same naming convention here.
Thanks.
volnay
Member
12 Points
8 Posts
Re: embedded gif webresource in a js behavior file
Dec 08, 2008 07:32 AM|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
Volnay
sacparker
Member
16 Points
3 Posts
Re: embedded gif webresource in a js behavior file
Aug 17, 2011 04:10 PM|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:
[assembly: WebResource("fr.MyAsembly.Ajax.name-of-file.js", "application/x-javascript", PerformSubstitution = true)]