I had the same problem today and it was solved using a custom code expression constructor .
Your code will look something like this:
<link rel="stylesheet" type="text/css" href="/css/main.css?v=<%$ Code:myVariable%>" />
The good tutorial that I used can be found here , which I was able to modify to fit my application. This will also work if you need to add code inside the server side control.
It was really easy to implement.
Here is what I added to my web.config :
<compilation debug="true"> <expressionBuilders> <add expressionPrefix="Code" type="CodeExpressionBuilder"/> </expressionBuilders> </compilation>
And in my App_Code folder, I created ExpressionBuilder.vb :
Imports Microsoft.VisualBasic Imports System.Web.Compilation Imports System.CodeDom <ExpressionPrefix("Code")> _ Public Class CodeExpressionBuilder Inherits ExpressionBuilder Public Overrides Function GetCodeExpression(ByVal entry As BoundPropertyEntry, ByVal parsedData As Object, ByVal context As ExpressionBuilderContext) As CodeExpression Return New CodeSnippetExpression(entry.Expression) End Function End Class
That is all I have done to make it work.
source share