13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

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.

152<strong>ASP</strong>.<strong>NET</strong> <strong>3.5</strong>: A Beginner’s <strong>Guide</strong>selection process the user opens the entire list. The very selection of an item changesthe selection, and that action can be captured in C#. The event handler property can beseen in the following code segment:…onselectedindexchanged="DropDownList1_SelectedIndexChanged"…The event, other than requiring AutoPostBack be set to true, is no different from anyof the other events used in conjunction with other Web forms. Its invocation is simplydifferent—it happens when an item is selected.ListBoxThe ListBox web control is an important addition because the user can easily see thecontents without having to open a menu. For a general user interface, you will find manyadvantages of using a ListBox over the DropDownList. The primary reason is that usersmay not know what to expect or where to look for something that they may want. Whilethe DropDownList is useful for saving space on a page, it can conceal information. Forexample, in the list of countries in Southwest Asia, the ListBox shown in Figure 6-15displays clearly countries about which most people know little.Were a DropDownList used instead, users might not know what to expect andmight make up the choices and waste time opening and closing the wrong pop-up menus.Using Both Text and Value Properties in List Web ControlsThe two list web controls are displayed in this next example. However, more importantly,you can see how both the Text and Value properties are used in the ListItem elements.In previous examples, either both properties were the same, or only one was used. However,in this next example, the Value property provides information about the Text value thatcan be passed on to a variable or to some other storage source by C#.<strong>ASP</strong>.<strong>NET</strong> Lists.aspxList Menu & Boxes

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

Saved successfully!

Ooh no, something went wrong!