Collections;
namespace ControlsBook2Web.Ch01
{
public partial class HelloWorld : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ArrayList list = new ArrayList();
list.Add("Hello");
list.Add("Goodbye");
Greeting.DataSource = list;
Greeting.DataBind();
}
protected void ClickMe_Click(object sender, EventArgs e)
{
Resultlabel.Text = "Your new message: " + Greeting.SelectedItem.Value +
" " + Name.Text + "!";
}
protected void Name_TextChanged(object sender, EventArgs e)
{
ChangeLabel.Text = "Textbox changed to " + Name.Text;
}
}
}
CHAPTER 1 ?– SERVER CONTROL BASICS 7
The server controls on our ???Hello, World??? web form (specifically, the Label, TextBox, and
DropDownList objects) render as HTML and, for the TextBox control, remember what is typed in
the control between postback cycles. The HTML rendered to the browser is backed by powerful
objects that can be wired up to programming logic to perform useful work on the web server.
During server-side processing, the object-oriented nature of server controls provides us with
three main constructs to interact with controls as objects: properties, methods, and events. We
discuss these constructs in the sections that follow.
Pages:
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54