"Pro ASP.NET 3.5 Server Controls and AJAX Components"
NET S TATE MANAGEMENT To test the page, click the Set Labels button on the web form to generate a postback to the web server. The button-click code in the code-behind class file sets the two label controls??™ Text properties. The postback itself gives our Textbox control the opportunity to receive data from the HTML form and set its Text property in its LoadPostData() implementation without any additional work needed in the test .aspx page. The emitted HTML control from the Textbox Render() method also sets the value of the tag, as shown in Figure 3-12. Figure 3-12. PostbackData.aspx after the first postback via the SetLabelButton control Next, click the Submit Page button to test the ViewState capabilities of the label controls and submit the Textbox data to the Textbox control yet again via another postback. The net result is that one label control can read from ViewState, and the other control reverts to its initial value, as shown in Figure 3-13. The use of ViewState for our Textbox control was not really necessary. A control based on an tag has built-in state management within the ASP.NET framework. The posted data of the tag is always returned to the control via LoadPostData(). However, we put the extra work here with ViewState to good use in the next chapter, which covers server control events.