I need to be able to programmatically determine the doctype of the current page (.aspx), whether its set directly within the page itself, or via a master page.
The reason is so I can output correctly formatted html from custom controls or components based on whether the doctype is plain html, xhtml, xml or whatever.
Use a literal tag for your doctype declarations and control it in code behind.