Search code examples
asp.netappsettingsexpressionbuildercompilationmode

ASP.NET ExpressionBuilder syntax - output AppSetting within img tag


I would like to use ASP.NET's ExpressionBuilder syntax to dynamically retrieve domain of static content from an AppSetting.

I am using the following syntax, which does not work:

<img src="<%$Appsettings:STATIC_CONTENT_DOMAIN %>/img/logo.jpg" alt="logo" width="176" height="159" />

FYI, the desired HTML output is:

<img src="http://static.myserver.com/img/logo.jpg" alt="logo" width="176" height="159" />

Please note, I cannot use <%= %> syntax because my ASPX page needs to be CompilationMode="never". (The reason I am using ExpressionBuilder syntax is that it works in no-compile pages)

Any ideas on how I can do this?


Solution

  • This approach worked for me (not very readable :)...

    <img src="<asp:Literal runat='server' Text='<%$Appsettings:STATIC_CONTENT_DOMAIN%>'/>/img/logo.jpg" />