Today I needed to include inline code within the HEAD section of an Web Form in order to dynamically include stylesheets based on the theme set for the application.
Below is an example:
<link href="../../Resources/Themes/<% = Page.Theme %>Grid.Default.css" rel="stylesheet" type="text/css">
Upon saving and viewing the page I noted that the code was not being interpreted and instead was being treated as a string literal. How to get around it? Add a panel control in the HEAD section and place the links to the stylesheets as in the example above within the panel. For whatever reason, ASP.NET does not want to interpret inline code in the HEAD section but will allow you to add .NET controls in the HEAD section.