As the title suggests, I'm trying to inject a doctype at runtime on a page-by-page basis.
The application uses a single master with a gazillion content pages, so naturally I've tried inserting an asp:contentplaceholder
control on the master, and using an asp:content
control on the content page. This works in that the doctype element shows up when you view source, but it doesn't work in that the browser (IE8) is still running in Quirks mode for some god-forsaken reason.
Here's the placeholder on the master:
<asp:contentplaceholder id="doctype" runat="server" />
Here's the content panel on the page:
<asp:content contentplaceholderid="doctype" runat="server" >
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
</asp:content>
I'm a bit baffled as to why this isn't working, since the replacement should happen server-side, then the output gets sent to the browser with the doctype already in place...
Why am I doing this?
I'm only doing this because specifying a doctype on the master means I would then need to go and fix the gazillion content pages before I can even begin to work on the assigned task. If I can figure out a way to inject a doctype via certain content pages, then I can effectively fix one page at a time until they are finished.
Which browsers does this affect?
Internet Explorer 8 is our primary target. It is, ironically, the browser that is effectively ignoring the injected doctype. When checking document.doctype
at runtime after the DOM is loaded, it's returning null
.
Firefox behaves differently. This technique actually works in Firefox, but doesn't really help [me] since all of our users are stuck with Internet Explorer 8.