This bug in MasterPage's HtmlHead control rendering is rather annoying to say the least. If head element is specified as runat="server" at design time it seems that ASP.NET renders all previously design-time defined tags as one literal control, which means - it renders all tags as one long string eating all line-breaks. Suppose the following head element in MasterPage markup like so:
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> < html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> < head runat="server"> < title>< /title> < meta http-equiv="content-type" content="text/html; charset=utf-8" /> < meta name="keywords" content="mykwords" /> < link href="/mycss.css" type="text/css" rel="stylesheet" /> < /head>
Now I go and set the title in the content page like so:
this.Header.Title = "My Title";
Expecting to get just the same markup for my head element with title string just inside title tag. I don't expect head element to be totally reformatted !
Instead, what I get is:
- All design-time tags are rendered as one long string without line-breaks.
- Title tag is rendered without line-break before and after.
- Title tag has 2 additional line-breaks before and after its innerHtml.
- Title tag has additional tab character after the line-break before its innerHtml starts.
LOL. Somebody has to take care of this...
Wednesday, January 10, 2007 4:25 AM