2011-03-29 59 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應該是有用的。