Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

C# + adding content to <HEAD>

Hi All,

I want to create a pageTemplate class.

I want to be able to add data into the <HEAD> section of the page.

How do I do it server-side in a .cs file?

Thanks a lot for any help.

Tuesday, September 30, 2003

How about creating a web user control (ASCX)?

Tuesday, September 30, 2003

I don't know if this is helpful, but...

I'm using Paul Wilson's version of MasterPages for templating, so what I'm doing to set page titles (while keeping the rest of the <HEAD></HEAD> section the same) is
1) In my template.ascx, I put runat="server" and id="pageTitle" tags on the TITLE tag.
2) In each pages's Page.Load event handler, I did this (hastily translated to C# from my VB.NET)

HtmlGenericControl pageTitle;
pageTitle = (HtmlGenericControl) Page.FindControl("pageTitle");
pageTitle.InnerText = "My Title Goes Here";

Dave Rothgery
Friday, October 3, 2003

You can do pretty much anything there, just stick in any old (asp-style) <% %> or <%= %> tags in the <head> </head> section and you have dynamic content.  I use this for the <link > and <title> parts of the <head>

Ezra Epstein
Tuesday, October 21, 2003

*  Recent Topics

*  Fog Creek Home