XHTML 1.0 Strict (or Transitional) compliance in ASP.NET 2.0/3.5

一曲冷凌霜 提交于 2019-12-05 01:21:38

ASP.NET 2.0 and above can indeed output Strict (or Transitional) XHTML. This will resolve your 'there is no attribute "name"' validation error, amongst other things. To set this up, update your Web.config file with something like:

<system.web>
    ... other configuration goes here ...
    <xhtmlConformance mode="Strict" />
</system.web>

For Transitional XHTML, use mode="Transitional" instead.

See How to: Configure XHTML Rendering in ASP.NET Web Sites on MSDN.

Have you considered the ASP.NET MVC Framework? It's likely to be a better bet if strict XHTML compliance is a requirement. You gain more control of your output, but you'll be treading unfamiliar territory if you're already comfortable with the traditional ASP.NET model.

Its possible to change the output of ASP.NET controls using techniques like the CSS Adapters. Although I wouldn't personally recommend you use these out of the box, it might give you some hints on a good solution.

I generally avoid using the ASP.NET controls where ever possible, except ones that don't generate markup on their own such as the Repeater control. I would look into the ASP.NET MVC framework (what StackOverflow is built on) as this gives you 100% control over markup.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!