0

I need to add the version at each css file, for that I have created a function which returns the build version, but when I add the function to the path it doesn't get properly rendered:

<!--Code-->
<link href="Styles/Site.css<% Version() %>" rel="stylesheet" type="text/css" />

<!--Render-->
<link href="Styles/Site.css&lt;% Version() %>" rel="stylesheet" type="text/css" />

I tried both <% %> and <%= %> and even using a global variable instead of a public function but with no results, however I was able to add the version to js files through modifyng the path in the ScriptManager object.

1 Answer 1

1

You can always add a stylesheet programatically.

 HtmlLink hl = new HtmlLink();

 hl.Href = "Styles/Site.css" + Version();
 hl.Attributes.Add("type", "text/css");
 hl.Attributes.Add("rel", "stylesheet");

 Page.Header.Controls.Add(hl);

The reason <%= %> does not work is because it is in the Head of the page, which is a Control in itself. If you put your sheet outside the Head, it does work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.