1

I have the following line:

<link href="<%= Links.Content.Site_css %>" rel="stylesheet" type="text/css" />

which is rendered to

<link href="Views/Shared/%3C%25=%20Links.Content.Site_css%20%25%3E" rel="stylesheet" type="text/css" />

So expression is not executed. If I remove quotes:

<link href=<%= Links.Content.Site_css %> rel="stylesheet" type="text/css" />

expression is executed but markup becomes xhtml incompatible. What is the right way to fix this problem?

Jason Berkan
  • 8,734
  • 7
  • 29
  • 39
SiberianGuy
  • 24,674
  • 56
  • 152
  • 266

3 Answers3

4

Just remove the runat="server" on your tag and it should fix it.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
2

Use single quotes instead of double quotes.

<link href='<%= Links.Content.Site_css %>' rel="stylesheet" type="text/css" />

For that special case, I'd use Css helper method from MVC futures assembly:

<%:Html.Css(Links.Content.Site_css) %>
Necros
  • 3,004
  • 23
  • 29
-1

This might be a workaround

<link href=<%= '"' + Links.Content.Site_css + '"' %> rel="stylesheet" type="text/css" />

(I have no experience with ASP, sorry if that's just invalid syntax)

Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301