I have in my C#, .NET 3.5 (VS2008) web project's App_Themes directory a theme directory called Theme1. In that directory I have various other directories. Some of theme contain .css files and some contain .js files. In my web pages, which use this theme, the appropriate link tags are rendered, in the HTML, for the .css files, but not the .js files. What am I doing wrong, or do I simply have to share all my .js files across all themes from a centralised directory?
-
Can you post an example <script> reference that isn't working correctly?roryf– roryf2010-08-13 09:57:57 +00:00Commented Aug 13, 2010 at 9:57
-
It's not the reference that isn't working, it's that ASP.NET doesn't render a script tag at all for the .js files inside the particular theme's directory.Matt W– Matt W2010-08-13 10:00:12 +00:00Commented Aug 13, 2010 at 10:00
Add a comment
|
1 Answer
If you place the JS files in your theme directory you can use the Page.Theme name to get the appropriate path for the current theme.
<script type="text/javascript" src="<%=ResolveUrl("~/App_Themes/" + Page.Theme + "/js/script.js") %>"></script>
3 Comments
Matt W
So, references to .js files are not include in the HTML by ASP.NET when they are placed inside theme directories?
Nathan Taylor
That is correct. You must individually specify what to load.
Basic
This does make sense as you're likely to have site-wide and page-specific js