SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 159 | Next

Robin Pars, Laurence Moroney, and John Grieb

"Foundations of ASP.NET AJAX"

This
markup is the only one updated upon a postback if the ScriptManager control is enabled
for partial updates. Consider Figure 5-7, where several text boxes and a button appear on
the screen. This application has two text boxes, two labels, and a button outside the
UpdatePanel control, and it has a label inside the UpdatePanel designer. The label on the
inside is called lblResult. The code behind the button reads as follows:
int x = Convert.ToInt16(txt1.Text);
int y = Convert.ToInt16(txt2.Text);
int z = x+y;
lblResult.Text = z.ToString();
CHAPTER 5 ?–  INTRODUCING SERVER CONTROLS IN ASP.NET AJAX 97
As you can see, the label for the result gets updated to the value of the sum of the values
of the text in the text boxes. Because lblResult is in the UpdatePanel control, and the
ScriptManager control is set to enable partial rendering, clicking the button updates only
the text within the UpdatePanel control. You will see and dissect more examples of this in
Chapter 6.
Figure 5-7. Simple application that uses the UpdatePanel control
Programming with UpdatePanel
The markup for the UpdatePanel control in the previous example is as follows:





CHAPTER 5 ?–  INTRODUCING SERVER CONTROLS IN ASP.


Pages:
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171