What is the right way to use the AttributeCollection.Render method?
-
05-09-2019 - |
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?
Solution
writer.WriteBeginTag(this.Tag);
this.Attributes.Render(writer);
writer.Write(HtmlTextWriter.TagRightChar);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow