H
Hardy Wang
Hi all,
I am building a Composite control, and I need to render Xhtml content for my
control. Here is my sample code:
protected override void Render(HtmlTextWriter output) {
XhtmlTextWriter xWriter = new XhtmlTextWriter(output);
xWriter.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
xWriter.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
xWriter.RenderBeginTag(HtmlTextWriterTag.Table);
xWriter.RenderBeginTag(HtmlTextWriterTag.Tr);
xWriter.RenderBeginTag(HtmlTextWriterTag.Td);
xWriter.Write("Hello world");
xWriter.RenderEndTag();
xWriter.RenderEndTag();
xWriter.RenderEndTag();
xWriter.AddAttribute("src", "logo.gif");
xWriter.RenderBeginTag(HtmlTextWriterTag.Img);
xWriter.RenderEndTag();
}
And here is the output
<table>
<tr>
<td>Hello world</td>
</tr>
</table><img src="logo.gif" />
Why attributes are not added to my table tag, but OK for img tag?
Do I miss something?
I am building a Composite control, and I need to render Xhtml content for my
control. Here is my sample code:
protected override void Render(HtmlTextWriter output) {
XhtmlTextWriter xWriter = new XhtmlTextWriter(output);
xWriter.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
xWriter.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
xWriter.RenderBeginTag(HtmlTextWriterTag.Table);
xWriter.RenderBeginTag(HtmlTextWriterTag.Tr);
xWriter.RenderBeginTag(HtmlTextWriterTag.Td);
xWriter.Write("Hello world");
xWriter.RenderEndTag();
xWriter.RenderEndTag();
xWriter.RenderEndTag();
xWriter.AddAttribute("src", "logo.gif");
xWriter.RenderBeginTag(HtmlTextWriterTag.Img);
xWriter.RenderEndTag();
}
And here is the output
<table>
<tr>
<td>Hello world</td>
</tr>
</table><img src="logo.gif" />
Why attributes are not added to my table tag, but OK for img tag?
Do I miss something?