SharePoint 2007 doesn’t like the xml:lang in my master page…

Hi there,

I recently needed to make a SharePoint portal XHTML compliant. My html tag was missing the “xml:lang” attribute. So I added it to the master page. That did not work however, SharePoint somehow stripped the “xml:lang” attribute, any other attributes added stayed ok.So after a few days I stumbled upon this article by Wouter van Vugt who explains how to make your MOSS XHTML compliant. I particularly liked the second step where he creates a custom HTML control and renders its attributes in code. See the article for the details. I hard coded the language, rather than get it from the CultureInfo.

For those who are thinking now: I’m not going to put code on my master page! Right you are. The code isn’t for your master page, but rather for a custom control on that page. So all you need to do is create an assembly (or better: add it in your solution) that has the new control and register its namespace at the top of the page. Then just use it in your page like so:

<loqlang:DynamicLanguageHtmlControl runat="server" dir="<%$Resources:wss, multipages_direction_dir_value %>">

Where I prefix my namespace “loqlang” and I called the control a DynamicLanguageHtmlControl. This must substitue the <html> and </html> tags. Wouter goes over these things quite fast and however he is very correct, the less experienced may be interested in this info.

Hope this helps you as it certainly helped me!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s