Geeks With Blogs
Title Of Blog


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.

Posted on Monday, January 31, 2011 10:23 AM ASP.NET | Back to top

Comments on this post: Inline code within HEAD section of ASP Web Form

# re: Inline code within HEAD section of ASP Web Form
Requesting Gravatar...
doesnt a panel render as a div?? maybe you can use a placeholder control instead
Left by Adam on Jan 31, 2011 11:03 AM

Your comment:
 (will show your gravatar)

Copyright © Jake Rutherford | Powered by: