This happens because the HtmlTitle control doesn't provide a RenderAttributes implementation. You can't (easily) subclass the control in this case but there's another option. The power of Control Adapters isn't limited to WebControls - the concept also extends to HtmlControls as well.
Drop the following in a *.browser file under the App_Browsers directory of your site:
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter
controlType="System.Web.UI.HtmlControls.HtmlTitle"
adapterType="HtmlTitleAdapter"
/>
</controlAdapters>
</browser>
</browsers>
Here's a prototype for the corresponding adapter:
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
public class HtmlTitleAdapter : System.Web.UI.Adapters.ControlAdapter
{
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
HtmlTitle title = Control as HtmlTitle;
writer.WriteBeginTag("title");
title.Attributes.Render(writer);
writer.Write(">");
if (title.Text != null)
writer.Write(title.Text);
writer.WriteEndTag("title");
}
}
Note that the internal render implementation of HtmlTitle differs somewhat:
protected internal override void Render(HtmlTextWriter writer)
{
writer.RenderBeginTag(HtmlTextWriterTag.Title);
if (this.HasControls() || base.HasRenderDelegate())
{
this.RenderChildren(writer);
}
else if (this._text != null)
{
writer.Write(this._text);
}
writer.RenderEndTag();
}
I'm not sure when a title would have child elements, so I don't think this an issue.
Hope this helps.
As an aside, it would be much easier to add this attribute on the client using jQuery.
<script type="text/javascript">
$(document).ready(function() {
$("title").attr("lang", "it");
});
</script>