ASP.NET Custom Server Controls: Dynamically Expandable Round Cornered Button - Closing the body (content) and creating the footer
(Page 6 of 7 )
In the previous section, we already opened the center cell. But we didn’t close yet. In this section we are going to close it.
writer.RenderEndTag() 'td
'middle right
writer.AddAttribute(HtmlTextWriterAttribute.Width, "0px")
writer.AddAttribute(HtmlTextWriterAttribute.Height,
"0px")
If Me.ImageMiddleRightURL.Trim.Length > 0 Then
writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundImage, "url(" &
Me.ImageMiddleRightURL.Trim & ")")
writer.AddStyleAttribute("background-repeat",
"repeat-y")
End If
writer.RenderBeginTag(HtmlTextWriterTag.Td)
writer.RenderEndTag() 'td
writer.RenderEndTag() 'tr
writer.RenderEndTag() 'table
The above is quite straightforward for closing the previously opened “<TD>” tag. But the above code is not part of the “RenderBeginTag” method. Instead, it is from the “RenderEndTag” method. We further proceed to create the footer row by adding the same type of code (with very few modifications) available in the “Creating the Header” section to the above code fragment. As the coding is quite similar, you can get it from the downloadable.
Everything up until now is quite okay. How did I implement the trick to get the “developer specified content” into my control? This is from the following code fragment.
Protected Overrides Sub RenderContents(ByVal writer As
System.Web.UI.HtmlTextWriter)
writer.Write(Text)
End Sub
Even though it is only three lines, it should be considered the heart of the control. In other words, when the control is getting rendered, it first executes the “RenderBeginTag” method followed by the “RenderContents” method and finally “RenderEndTag”. For a detailed explanation of “rendering” issues, I suggest you to refer my previous articles of the same series.
Next: How did I handle the postbacks? >>
More ASP.NET Articles
More By Jagadish Chaterjee