开发者

validate asp.net xhtml strict via URI

开发者 https://www.devze.com 2023-02-20 11:03 出处:网络
I have an asp.net website which is using the xhtml strict dtd & making use of xhtmlConformance mode in web.config.

I have an asp.net website which is using the xhtml strict dtd & making use of xhtmlConformance mode in web.config. When validated by source I get zero err开发者_如何转开发ors but when by URI I get 2 errors

there is no attribute "name"

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

I don't know where that name attribute has come from. It doesn't exist in the outputted xhtml.

The second error is because it sees the viewstate as not being wrapped in a div, (even though it is).

Not sure what's happening.


The reason why a name attribute is being generated is because ASP.NET automatically creates a name attribute if you do not specify one.

According to a 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.

However, there is a way to drop the name attribute: Use XHTML Fixes. (See this ASP.NET forum thread for more information.)

About your second <div> error: can you copy the source code from your browser (not the source you wrote) and paste it there? That will help us find the issue with that error.

EDIT: This question about validating ASP.NET as XHTML 1.0 Strict should be useful.

0

精彩评论

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

关注公众号