Wednesday, August 14, 2013

ASP.NET HEAD runat server

The HEAD tag within an ASPX file typically has a runat="server" atttribute to make it into a server control. A lot of programmers wondered why this was necessary. Well, it is not but if you do turn it into a server side control, you get the ability to dynamically add tags into the HEAD tag and get URL resolution as well (and it provides the ability to use the tilda to generate absolute URLs). For example, the Page object has a Title attribute and you cannot use it unless you make the HEAD a server side control. Similarly, you can add meta tags 'programatically' instead of placing it within a markup - why would you want to do something like that is something the CMS folk can answer from their experience of getting the page information from a database of a content management system and using the ASPX markup as a mere template.

No comments: