2011-03-29 62 views
0

我有一个asp.net网站,它使用xhtml严格dtd ​​&在web.config中使用xhtmlConformance模式。 当源验证我得到的零个错误,但是当通过URI我得到2个错误通过URI验证asp.net xhtml strict

没有属性“名”

<form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm"> 

我不知道这个名字属性都来自。它不存在于输出的xhtml中。

第二个错误是因为它将viewstate视为未被包装在div中(即使它是)。

不知道发生了什么事。

回答

0

生成name属性的原因是因为如果您未指定属性,ASP.NET将自动创建一个name属性。

根据MSDN article

A form must have a unique name. One is assigned automatically by ASP.NET if you don't specify one. You can set the form's identifier by using either the ID or Name property. If both are set, the ID attribute takes precedence. It is important to note, though, that any programmatic use of the Name attribute compromises the XHTML compliance of the page. In XHTML, elements are identified by ID and not by Name. So generally speaking, you're better off relying on the ID property.

但是,砸name属性的方法:使用XHTML Fixes。 (有关详细信息,请参见this ASP.NET forum thread)。

关于第二个问题<div>错误:您是否可以将源代码从浏览器(不是您写的源代码)复制并粘贴到那里?这将帮助我们找到该错误的问题。

编辑:This question about validating ASP.NET as XHTML 1.0 Strict应该是有用的。