Determining doctype of current page or master page programmatically
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.
I can't think of a way to reliably do what you want to do. You could obviously manually parse the master page but that wouldn't handle the dynamic case. I would recommend adding an attribute to your control that specifies the rendering mode and force your consumers to set it (default to XHTML probably since that's the VS default).
加载中,请稍侯......
精彩评论