Inline code within HEAD section of ASP Web Form

 

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.

Print | posted on Monday, January 31, 2011 10:23 AM

Feedback

# re: Inline code within HEAD section of ASP Web Form

left by Adam at 1/31/2011 11:03 AM Gravatar
doesnt a panel render as a div?? maybe you can use a placeholder control instead
Post A Comment
Title:
Name:
Email:
Comment:
Verification: