Question

Possible Duplicate:
Inline tag not executing in an asp.net master page

I have the following lines in my master page:

<script type="text/javascript" src="/Scripts/TimeClock/Themes/<%= ThemeName %>/jquery-ui-1.9.2.custom.min.js"></script>

<link href="/Styles/Themes/<%= ThemeName %>/jquery-ui-1.9.2.custom.css" rel="stylesheet" type="text/css" />

Everything compiles fine, but when I run my web application, my css file doesn't load. The reason is because when I view source on the rendered page, this is what appears:

<script type="text/javascript" src="/Scripts/TimeClock/Themes/Smoothness/jquery-ui-1.9.2.custom.min.js"></script>

<link href="/Styles/Themes/&lt;%= ThemeName %>/jquery-ui-1.9.2.custom.css" rel="stylesheet" type="text/css" />

So it appears my ASP.NET Server tag is working for the script line, but not the CSS line. Does anyone know what I am doing wrong and how to fix this?

Was it helpful?

Solution

When you place it inside the header and the header contains the run at server then you can not use this with out pass from the header filter that also change that part that you have the issue.

To by pass it use a literal control and fully render it on code behind, eg as:

<asp:Literal runat="server" id="txtScriptOnheader" EnableViewState="false" />

and on code behind:

txtScriptOnheader.Text = "<link href=\"/Styles/Themes/\""  + ThemeName + "/jquery-ui-1.9.2.custom.css\" rel="stylesheet\" type=\"text/css\" />";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top