Q:

ASP.NET string interpolation for attributes

I am simply trying to insert a variable into a favicon link
<link rel="shortcut icon" href="<%=Favicon%>" type="image/x-icon" />

It works when I don't have to quote the text.  
I have Favicon defined in the Page_Load and I'm using interpolation to generate the page title without problem. 

A:

Try this instead...
Page:
<link runat="server" rel="shortcut icon" type="image/x-icon" id="favIcon" />

Page_Load:
favIcon. Attributes. Add("href", Page. ResolveUrl("~/PathTo/somecool.ico"));

A:

So here's what I found.  It seems to be an issue with the link tag in the head.  Copy the exact same code and put it in the body and it works.  Take the following and put in the head and it populates as expected: <div id="<%= Favicon %>"><%= Favicon %></div>
Work arounds:
Take quotes out of the element and put them in the string:
Markup: note no quotes for href
 <link rel="shortcut icon" href=<%= Favicon %>  type="image/x-icon" />

C#: quotes added to string
public string Favicon = "\"//www.alink.com/toAnImage.ico\"";

I think Scotty's approach may be better though

