WriteEndTag("h3");
Rendering the Table
Once the control header content is rendered, we move on to building the HTML table in the
RenderTable() method. This portion of the control demonstrates a nifty feature of the
HtmlTextWriter in working with HTML attributes. The AddAttribute() method takes a key/value
string pair for each attribute you wish to render on an HTML tag. You can call this method
multiple times to build up as many attributes to the follow-on tag as necessary. Once you??™ve
finished adding attributes, the next step is to use the RenderBeginTag() method. This method is
smart enough to look at the attributes that were added previously and render them into the
final output stream along with the tag name and brackets. The RenderTable() method uses this
functionality to build the
tag and add a Border attribute to it:
// write
writer.AddAttribute(HtmlTextWriterAttribute.Border,"1");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
EqualsDoubleQuoteString =""
SelfClosingChars /
SelfClosingTagEnd />
SemicolonChar ;
SingleQuoteChar '
SlashChar /
SpaceChar Space
StyleEqualsChar :
TagLeftChar <
TagRightChar >
Table 2-1. String Fields Exposed by HtmlTextWriter (Continued)
HtmlTextWriter Field String Output
CHAPTER 2 ?– ENCAPSULATING FUNCT IONALITY IN ASP.
Pages:
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136