15.02.2015 Views

C# 4 and .NET 4

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

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

1166 ❘ ChaPTer 40 cOre Asp.net<br />

ErrorMessage="You must enter an event name."<br />

ControlToValidate="eventBox" Display="None" /><br />

<br />

<br />

Most of the ASP.<strong>NET</strong> code in this file is remarkably simple, <strong>and</strong> much can be learned simply by reading<br />

through it. Of particular note in this code is the way in which list items are attached to the controls for<br />

selecting a meeting room <strong>and</strong> multiple attendees for the event:<br />

<br />

<br />

Meeting Room:<br />

<br />

<br />

The Happy Room<br />

The Angry Room<br />

The Depressing<br />

Room<br />

The Funked Out<br />

Room<br />

<br />

<br />

<br />

<br />

<br />

<br />

Attendees:<br />

<br />

<br />

Bill Gates<br />

Monica Lewinsky<br />

Vincent Price<br />

Vlad the Impaler<br />

Iggy Pop<br />

William<br />

Shakespeare<br />

<br />

Here you are associating ListItem objects with the two web server controls. These objects are not web<br />

server controls in their own right (they simply inherit from System.Object), which is why you don’t<br />

need to use Runat=“server” on them. When the page is processed, the entries are used<br />

to create ListItem objects, which are added to the Items collection of their parent list control. This<br />

makes it easier for you to initialize lists than to write code for this yourself (you would need to create a<br />

ListItemCollection object, add ListItem objects, <strong>and</strong> then pass the collection to the list control). Of<br />

course, you can still do all this programmatically if you want.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!