Prev | Current Page 237 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"

LoadViewState(state[2]);
}
}
154 CHAPTER 4 ?–  T HE WEBCONTROL BASE CLASS AND CONTROL S TYLES
LoadViewState() casts the incoming parameter to an object array identical to what we used
to persist style information in SaveViewState(). We next call LoadViewSate() for each Style class,
checking to ensure that we don??™t have a null reference before loading state from ViewState. Order
matters, so WebControl LoadViewState() goes first followed by the Label and TextBox controls??™
LoadViewState() routines. At the end of the InputBox LoadViewState() routine, we can be assured
that the saved ViewState is retrieved from the postback and is ready to go for rendering.
Rendering the Output
Normally, a composite control leaves the rendering to the base class implementation of Control or
WebControl. Because we are doing our own custom style work, we override Render() for the
maximum amount of control. In our Render() method override (shown in the following code
snippet), we need to call RenderBigTag() to emit the starting
tag and the base style properties,
we need to call RenderChildren() to have the child controls render their content, and finally, we
need to call RenderEndTag() to emit the closing
tag. We skip calling RenderContents(),
because we took full responsibility for rendering the control, including the inner HTML.


Pages:
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249