如何修改DNN默认的DOCTYPE

DNN 4.4版本新增了皮肤级别DOCTYPE的支持,允许用户为不同皮肤设置特定的DOCTYPE声明。本文介绍两种实现方法:一种是通过创建XML文件来指定DOCTYPE;另一种是在HTML或ASCX皮肤文件中直接使用服务器端代码来设置DOCTYPE。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

DNN 默认的DOCTYPE在IE 6.0下会触发IE进入quirks模式( 会有什么影响),那如何修改DNN的DOCTYPE呢? Cathal Connolly 给出了一个解决方案

原文:
Whilst the 4.4 release predominantly focussed on performance and optimisation, there were a number of other enhancements added to the release (as always the changelog is the best place to view changes). One of these, that should be of interest to skinners and those interested in accessibility standards & xhtml compliance, is support for skin level doctypes .

Historically, if you wanted to target your skin/container for a particular version of html/xhtml, you had to manually edit the default.aspx page to alter the hardcoded DOCTYPE declaration. With 4.4, the declaration has been made dynamic, to allow users to declare particular doctypes with particular skins. To make use of this, you create a file with the same name as your skin except ending in doctype.xml (rather than ascx/htm/html) and it’ll be picked up during skin load. This xml file should contain a single node,SkinDocType, that contains a declaration of your desired doctype. To ensure that the parser reads the value correctly, you need to use a CDATA section to escape out the various < and & characters e.g. If I have a skin called mypage.asx that I intended to render as XHTML 1.0 strict, then I would create a file called mypage.doctype.xml which would  contain the following:

<SkinDocType><![CDATA[<!DOCTYPE XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]></SkinDocType>


对此 John Mitchell认为这个解决方案不灵活,每次页面加载的XML解析会降低效率,他提出的解决方案如下:

原文:
Brand new in DNN 4.4 is the option to change your Doctype  which Cathal blogged about.

As Cathal pointed out in this thread the implementation will need to be improved for performance because on every request the DNN framework is looking for an XML file and loading it into an XML Document to validate the XML.

There is also concern that it is hard to implement with multiple skins because you would need a different XML file for every Skin.

You can shortcut all of this now and not take the performance hit by using the code below.

Just copy and paste the following code directly into your HTML or .ASCX skin file.

< script runat = " server " >
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   Dim skinDocType 
as  Control  =  Me.Page.FindControl( " skinDocType " )
   If Not skinDocType 
is  Nothing
      CType(skinDocType, System.Web.UI.WebControls.Literal).Text
= " <!DOCTYPE html PUBLIC  "" -//W3C//DTD XHTML 1.0 Strict//EN ""   "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd "" > "
   End If
End Sub
</ script >

时间有限,就不翻译了,贴出来供大家参考。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值