Xpode.com        Click here to Print this article.

What is output.RenderEndTag

Tag is used while creating the Custom COntrol. While form renders it Creates HTML and convert the controls in the HTML Tags.

while creating Custom COntrol, It creats the HTML tag i.e. Span (depending upon the nature of tag) having id. In that What we write output.RenderEndTag() at the end so that This span tag can be close.
If we will not write the output.RenderEndTag(). The tag will not have closing tag.


protected override void RenderContents(HtmlTextWriter output)
// output.Write(Text);
output.AddAttribute(HtmlTextWriterAttribute.Href, "http://google.com");
output.AddStyleAttribute("font-size", "20px");
output.AddStyleAttribute("color", "#000000");
output.AddStyleAttribute("font-weight", "Bold");
output.AddStyleAttribute("text-decoration", "none");
// output.RenderEndTag();


Without output.RenderEndTag() It will show in HTML side:

< span id="WebCustomControl1_1">
< a href="http://Google.com"
style="font-size: 20px; color: rgb(0, 0, 0); font-weight: bold;
text-decoration: none;">Google.com< /a>
Have you noticed that Span tag have not end tag.


Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com

Click here to go on website