Navigation

Search

Categories

 
 
 
 
 
 
 
 
 

On this page

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 8
This Year: 0
This Month: 0
This Week: 0
Comments: 5

Sign In
Pick a theme:

# Thursday, 21 December 2006
Thursday, 21 December 2006 16:26:55 (GMT Standard Time, UTC+00:00) ( .net | MCMS | Reflection | W3C | Xhtml )

If you don't use MCMS, you can still use a big part of this Christmas gift, so read on.

Have you ever tried making Xhtml Valid website's with MCMS, I think not many of you have.

I ran in to this too, but only after trying a part of the solution for another reason.  That reason was to fix the broken Action in the Html form.
I found some solutions on the internet to fix this issue for Url Rewriting in pure .Net (1.1) websites.
(This one for example: http://www.liquid-internet.co.uk/content/dynamic/pages/series1article1.aspx)
This article shows how to remove the name attribute and change the action path to something else, like say... the MCMS 'nice' url.

Everything seemed to work just fine, untill.... I added the console on the page which has to be in the form.  There is a bug in the console code that checks if the console is placed inside an HtmlForm.  The check does a hard check like this:

if(typeof(System.Web.UI.HtmlControls.HtmlForm) == formobject.GetType())

Instead of

if(formobject is System.Web.UI.HtmlControls.HtmlForm)

This makes inheriting the HtmlForm control impossible when using MCMS.  But, luckily, there is a solution called reflection, which is also used on the code from the other article.
With Reflection it was possible to override the OnInit method and still fill all private variables and call all private methods.  I had already abandoned this Idea in the initial project beause it was taking too long for the purpose.  But around eight months later there appeared a problem.  The dutch government requests that their websites are now XHTML1.0 Strict.  This was not possible since the HtmlForm could not be overridden.  Since we work alot for the government we had to find a solution to that problem.... which I had almost solved when I could write to private variables (couldn't find how to do that because it uses FieldInfo class where I expected something with 'Variable' in the name.  But eight months later there was something more in google about reflection and private variables so this time I founc which class to use and I could finish the job.

At that point I had full control over what was possible with the HtmlForm and the Console for MCMS.  I've overridden them both and changed them extensively to make the scripts that are rendered Xhtml valid without breaking the old functionality.

Another great feature that came with this endless possibilities was that I could determine myself where to put the viewstate.  Maybe you know, maybe you don't but when google harvests your webpage it only reads the first few kilobytes of your website.  If your website has a large viewstate (which you should prevent anyway) then you can choose to place it on the bottom of the form instead of the Top (the default).  You should be careful though, because if your application depends extensively on viewstate and the page is not completely loaded your application might break because viewstate is not fully loaded yet.

To do all this functionality I had to override and re-implement lots of code from Microsoft.  I used the .NET Reflector to get to the original code.  Luckily this is possible because we would have had a big problem and we would definitely loose the government as a customer.

I haven't placed many code here because the code sample wil be self explanatory with the comments.

All I can say now is, good luck with developing all your other code Xhtml Valid.  Because it can be done!

Sandro

XhtmlValidForm.zip (10.11 KB)

Edit: I found a link that shows that someone else has stumbled on this too, but unfortunately there was no solution for him at that time: http://www.webservertalk.com/message535195.html

Friday, 23 May 2008 00:04:37 (GMT Daylight Time, UTC+01:00)
That makes sense.
Comments are closed.