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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Figure 3-8. Adding a list dynamically<br />

You would then create an event-h<strong>and</strong>ler function. This function takes a parameter,<br />

sender, which is a generic object that you can then cast to get the list box. Now that you<br />

have a list box, you have full IntelliSense in development so that you can h<strong>and</strong>le it. Here’s<br />

an example:<br />

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

{<br />

ListBox theBox = (ListBox)sender;<br />

String strTest = theBox.SelectedItem.Text;<br />

}

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

Saved successfully!

Ooh no, something went wrong!