Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Changing <head> from a .ascx

I want to create an .ASCX that I can drop into any ASPX page and have it insert some lines into the <html><head> area of the resulting html page.

I am foxed as to how to do it though!

I don’t want to have to put any marker in the ASPX page.

I cannot craft a Google search that is leading me anywhere useful. Never a good sign...

Aidan
Friday, July 02, 2004

The first thing that I would ask you is what are you trying to specify in your <head> area?

The reason that I ask is because some things can be solved through Javascript, if you are ok with using that. For example, in one .NET user control that I developed, I referenced the Javascript DOM to alter the title of the page, since there was no solution that I came up with to alter <head><title> from within my user control.

The second approach that I have also used and more commonly use for this is to modularize my user controls with parameters, and have common Page interfaces and classes that my pages inherit from, which have properties for common things (i.e. such as PageTitle).

Toronto .NET
Friday, July 02, 2004

I was messing around with a portal system (based on the ibuyspy thing MS produced) and was thinking of having a 'module' that could be used to change the CSS file used by the page. This in order to allow basic "skinning" of the site.

I have decided that this is not the correct approach, however I have not done anything else, as other priorities have taken over.

Thanks for your response though!

Aidan
Tuesday, July 13, 2004

In the codebehind page (vb sample)....

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

writer.Write("blah")

    End Sub

Peter
Monday, July 19, 2004

*  Recent Topics

*  Fog Creek Home