开发者

Output html to page in inherited PageBase class

I've inherited (no pun intended) an old ASP.NET 1.1 pr开发者_C百科oject 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">
    <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!


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜