views:

13

answers:

2

I've inherited (no pun intended) an old ASP.NET 1.1 project that is now .NET 3.5. It is designed with base class that inherits from PageBase. All of the subsequent aspx pages inherit from this custom pagebase. It currently works by generating a bunch of html text in LiteralControls for the headers and navigation bars and dropping it into an HtmlGenericControl (in this case called 'page'), which is then displayed on the page by using this.Controls.Add(page); This actually works, except for the following output:

<span>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd"&gt;
    <html>
         ...
   </html>
</span>

Those span's aren't supposed to be there obviously, but they come from the HtmlGenericControl, which defaults to a tagName of span. This is causing some strange behavior in IE regarding centering controls on the page.

Basically I know I should be using masterpages for this type of thing, but I don't have time to switch this all over, and I'm not an ASP.NET expert yet to where I know exactly how to solve this problem. Is there another way of sending literal text directly to the HTML output without wrapping it in a control? Obviously I need the DocType to be the first thing on the page; nothing wrapping it. Thanks!

+1  A: 

Can it use a LiteralControl instead of HtmlGenericControl? I don't think those decorate output with surrounding tags.

David
A: 

Worst case, use a HttpModule to alter the output and get rid of the spans.

CyberDude