|
||||||||||||||||||
|
||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionThis is all about standards. When you want to write a new web browser you need to start from start. But what is start? Standard, of course. Your new web browser have to implement standard or a couple of standards. You probably heard about HTML, it comes from 'hyper text markup language', first standard for web pages. So, when your application valid to a standard and web browsers have implemented same standard, you may be sure your page will look the same on each of them. XHTML is a new gen standard, next step from HTML, that on its mission holds to separate program code from presentation level. According to it you have to place all presentation markups into style sheets. More about XHTML1.1 you can read here. 2001 year, not so new, but even today not many websites can be valid against this. Making your website valid against XHTML1.1 shows not only you as man (woman) who understands problem and strength of standardization, it also makes your web application to be more manageable and teach you to make it more logically constructed. Let's make W3C-validator HappyBest way to start with validation check is source, of course: http://validator.w3.org/ 1st Step: Adding Valid DOCTYPE and HTML TagAdd this to each .aspx page or just to .master page <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
2nd Step: Bringing ASP.NET Application into 'Strict' ModeMost simple action. Just add this line into web.config file. <system.web>
<xhtmlConformance mode="Strict" />
3nd Step: Cleaning MarkupMake all markups according to xhtml standard. 4th Step: Going crazy... jokeEvery steps with ASP.NET was performed by you, but those two errors stayed:
What to do? Yep, this question can make you mad, 'cause you have cleaned your code, all markups are clean. When you view source code of response you see: <body>
<form method="post" action="default.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwULLTE3OTA2NzE4NzhkZNfmNwEXXdZH1+AqEfOHXBehT/kY" />
</div>
Which is valid against XHTML1.1 but when you check with W3C validator it shows those errors and source code looks like this: <body>
<form name="aspnetForm" method="post" action="default.aspx" id="aspnetForm">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwULLTE3OTA2NzE4NzhkZNfmNwEXXdZH1+AqEfOHXBehT/kY" />
Where is problem? ASP.NET and .NET Framework v2.0 (v3.0, v3.5) does not include the Validation Service engine in their recognized browsers and the rendered code gets 'downleveled' when rendered. This produces the errors in code that is sent to the Validation Service engine thus causing the code not to validate. (Craig Thacker comments at W3C bugzilla). So, as workaround, you have to assign W3C validator client by yourself. 4th Step: Assign W3C Validator CapabilitiesCreate App_Browsers folder in webroot directory, and file with .browser extension. It must contain next code: <!-- App_Browsers/w3g.browser
http://www.w3.org/Bugs/Public/show_bug.cgi?id=3734
-->
<browsers>
<browser id="W3C_Validator" parentID="default">
<identification>
<userAgent match="^W3C_Validator" />
</identification>
<!--
<capture>
<userAgent match="NewBrowser (?'version'\d+\.\d+)" />
</capture>
-->
<capabilities>
<capability name="browser" value="W3C Validator" />
<capability name="ecmaScriptVersion" value="1.2" />
<capability name="javascript" value="true" />
<capability name="supportsCss" value="true" />
<capability name="tables" value="true" />
<capability name="tagWriter" value="System.Web.UI.HtmlTextWriter" />
<capability name="w3cdomversion" value="1.0" />
</capabilities>
</browser>
<!--
<browser refID="Mozilla">
<capabilities>
<capability name="xml" value="true" />
</capabilities>
</browser>
-->
</browsers>
Now, validator will show green 'This document was successfully checked as XHTML 1.1!' History
|
|||||||||||||||||