08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3 ■ WEB FORMS WITH <strong>ASP</strong>.<strong>NET</strong> 61<br />

You can see how this looks in Design view in Figure 3-5.<br />

Figure 3-5. Viewing the page in Design view<br />

You can see how these controls are held within the Page object by executing the<br />

following code:<br />

protected void Page_Load(object sender, EventArgs e)<br />

{<br />

foreach(Control ctrl in Page.Controls)<br />

{<br />

ListBox1.Items.Add(ctrl.GetType().ToString() + ":" + ctrl.ID);<br />

}<br />

}<br />

This code will access the Page.Controls collection <strong>and</strong> cycle through it, taking the<br />

type <strong>and</strong> ID of the control <strong>and</strong> adding them to the list. You can see the results of the code<br />

in Figure 3-6.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!