Question

I've created a web control and I want to pass the element attributes through during the render phase. I would prefer use writer.RenderBeginTag() and RenderEndTag() but this is the only way I can seem to integrate the attributes successfully:

public override void RenderBeginTag(HtmlTextWriter writer)
{
    writer.Write("<");
    writer.Write(this.Tag);
    this.Attributes.Render(writer);
    writer.Write(">");
}

Is there another way to do this without looping through the Attributes collection?

Was it helpful?

Solution

writer.WriteBeginTag(this.Tag);
this.Attributes.Render(writer);
writer.Write(HtmlTextWriter.TagRightChar);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top