NET TextBox control and substitution of the one we just created. It has
the button setup you have become familiar with: one button sets the value of the labels, and
the other button recycles the form to exercise ViewState. Because the Textbox control receives
its own postback data, we do not need to set its value in the code-behind class explicitly or
worry about maintaining its state.
The initial page in Figure 3-11 looks identical to the previous web form that demonstrated
our labels. Our Textbox control performs admirably well as a substitute for the ASP.NET builtin
version of the control. Listings 3-9 and 3-10 contain the source code for this demonstration.
112 CHAPTER 3 ?– ASP.NET S TATE MANAGEMENT
Figure 3-11. PostbackData.aspx after the first request
Listing 3-9. The Postback Data Web Form .aspx File
<%@ Page Language="C#" MasterPageFile="~/MasterPage/ControlsBook2MasterPage.Master"
AutoEventWireup="true" CodeBehind="PostbackData.aspx.cs"
Inherits="ControlsBook2Web.Ch03.PostbackData"
Title="Postback Data Demo" %>
<%@ Register TagPrefix="apress" Namespace="ControlsBook2Lib.Ch03"
Assembly="ControlsBook2Lib" %>
Width="14px">3 ID="ChapterTitleLabel" runat="server" Width="360px">
ASP.
Pages:
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199