
Being a primarily Microsoft based developer you may automatically assume that I am anti-standards and that I have no intentions to write readable code. I can put up with the armature hobbyist making such claims, but when Microsoft themselves felt there was no value to implement standards to their server generated code in ASP.NET 1.1, I start to wonder to myself what else is wrong with the software that I use. I would hate to think that when the subject was brought up by the programmers at microsoft simply came back with the "does it look good in ie" response.

Saying that as it will, being a primarily microsoft based developer i was a little late to jump on the bandwagon of XHTML compliancy. I finally decided that standards though a pain in the neck were extremely important. As the internet becomes older, web sites become older and in turn the code of the web sites become older. People get fired, move on and others are left to deal with the mess that they left behind. Malformed code in small doses may not be the end of the world, but when multiple programmers over many years all add their malformed code to the mix it starts to become a serious problem. Pages begin to load slower and slower and errors occur at an increasing rate. This leaves the company and the current employees with a huge headache of cleaning up the code. Before standards became the norm it was thought that this was just a normal practice that would need to be done every 2 to 3 years. But now with standards a site that adheres to strict standards policy will no longer have this problem, theoretically. They can also be sure that their page will work in any web browser, and with the increasing amount of internet ready devices this becomes important.
So that being said I decided to develop my first strict standards/CSS based web site in asp.net, after all i am a vb developer. After pulling my hair out
(it can be hard to teach an old dog new tricks) developing my standards based layout you can imagine how perturbed I was when I put in my asp.net controls and they produced non compliant code. So began my search for a solution.
I first stumbled on a few solutions that used regular expressions (
link ) or functions that override the render method (
link ). Though good in theory both of these slow down the output of you asp drastically, which was one of the original reasons I was developing a standards compliant site to begin with. Microsoft had made very simple mistakes that made their output invalid such as Capitalizing a word when it was not supposed to be or adding non supported attributes. It seemed silly to slow down the load time of my page just simply to transform my html so it would pass a compliancy check.
Continuing my search I found a programmer named
Kevin Brown who best used the override render method in his article
Valid XHTML within .NET. Working with his solution i was able to correct some of the problems I was having. Though in his model I did not notice any real load issues, I did note that there must be some additional strain on the server and that over time the server was working harder to render a page. I also noticed that it was not in tune with standards based compliancy to use a method like this. If a programmer were to try and take over this project 5 years from now, I do not see how he could have any idea what exactly was going on or why in fact it was going on in the first place.
So in the end what I decided to do was take the leap into the world of beta to see if Microsoft did in fact correct the problem in the release of ASP.NET 2.0. To much of my surprise after installing the framework 2.0 beta is that my errors were dramatically decreased. They fixed all of the capitalization problems as well as the attribute problems. The only issues that I still found were formatting problems. But the solution for that was easy, simply omit any formatting tags in you asp.net controls and define your fonts and formatting outside of the control using CSS.
For example I stripped down the code for my calendar control to:
<asp:Calendar ID="Calendar1" runat="server"
OnSelectionChanged="Calendar1_SelectionChanged"
ShowTitle="true" DayNameFormat="FirstTwoLetters"
SelectionMode="Day" BackColor="#FAFDFE"
FirstDayOfWeek="Monday" Width="120" >
<titlestyle font-size="X-Small" borderwidth="0px" forecolor="#333399" backcolor="#FAFDFE" />
<nextprevstyle backcolor="#FAFDFE" forecolor="#000000" />
<othermonthdaystyle forecolor="#c0c0c0" />
<selecteddaystyle forecolor="White" backcolor="#333399"></selecteddaystyle> <todaydaystyle backcolor="#b1cee2">
</todaydaystyle>
</asp:Calendar>
<asp:Literal id="Literal1" runat="server"></asp:Literal>
The code that is output from the server. Is now XHTML compliant.
To download the .NET Framework Version 2.0
(link)
Though not required to write XHTML compliant code in ASP.NET you may also want to install the framework SDK. This will give you access to new classes and
web controls only available in ASP.NET 2.0
.NET Framework 2.0 SDK
(link)