What is the correct way to use the AttributeCollection.Render method?

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

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

Is there any other way to do this without looping through a collection of attributes?

+3
source share
1 answer
writer.WriteBeginTag(this.Tag);
this.Attributes.Render(writer);
writer.Write(HtmlTextWriter.TagRightChar);
+4
source

Source: https://habr.com/ru/post/1703598/


All Articles