开发者

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).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜