views:

53

answers:

3

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?

A: 

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
+2  A: 

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
+2  A: 

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

David Ebbo