Syntax ASP.NET ExpressionBuilder - AppSetting output in img tag

I would like to use ASP.NET ExpressionBuilder syntax to dynamically fetch a domain of static content from AppSetting.

I use the following syntax that does not work:

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

FYI, the desired HTML output:

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

Please note: I cannot use the syntax <% =%> because my ASPX page must be CompilationMode = "never". (The reason I use ExpressionBuilder syntax is because it works on pages without compilation)

Any ideas on how I can do this?

+3
source share
3 answers

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

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

, - . :

, :

<%$ MyCdnUrl: Static, '/img/logo.jpg' %>

":" URL-, .

, " ", . - <img runat="server"> <asp:Image> <img> <asp:Literal> .

+2

, asp.net , :

<asp:Image ID="MyImage" runat="server" ImageUrl="<%$Appsettings:STATIC_CONTENT_DOMAIN %>" />

, , , :

<asp:Image ID="MyImage" runat="server" ImageUrl="<%$Appsettings:STATIC_CONTENT_DOMAIN %>/img/logo.jpg" />

, , . ...

0

Source: https://habr.com/ru/post/1730263/


All Articles