<asp:ListItem Text="Tacos" Value="tacos" />
<asp:ListItem Text="Pasta" Value="pasta" />
</asp:CheckBoxList>
BulletedList
The BulletedList control displays bulleted or numbered lists, using <ul> (un-
ordered list) or <ol> (ordered list) tags. Unlike the other list controls, the
BulletedList doesnt allow the selection of items, so the SelectedIndexChanged
event isnt supported.
The first property you'll want to set is DisplayMode, which can be Text (the de-
fault), or HyperLink, which will render the list items as links. When DisplayMode
is set to HyperLink, you can use the Click event to react when the user clicks
on one of the items.
The other important property is BulletStyle, which determines the style of the
bullets. The accepted values are Numbered (1, 2, 3, ), LowerAlpha (a, b, c, ),
UpperAlpha (A, B, C, ), LowerRoman (i, ii, iii, ), UpperRoman (I, II, III, ),
Circle, Disc, Square, and CustomImage. If the style is set to CustomImage, youll
also need to set the BulletStyleImageUrl to specify the image to be used for
the bullets. If the style is one of the numbered lists, you can also set the
FirstBulletNumber property to specify the first number or letter thats to be
generated.
Advanced Controls
These controls are advanced in terms of their usage, the HTML code they gener-
ate, and the background work they do for you. Some of these controls arent
available to older versions of ASP.NET; well learn more about many of them (as
well as others that arent covered in this chapter) as we progress through this
book.
Calendar
The Calendar is a great example of the reusable nature of ASP.NET controls.
The Calendar control generate the markup to display an intuitive calendar in
which the user can click to select or move between days, weeks, months, and so
on.
The Calendar control requires very little customization, and can be created
within a page like this:
112
Chapter 4: Constructing ASP.NET Web Pages
File: Calendar.aspx (excerpt)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Calendar Test</title>
</head>
<body>
<form runat="server">
<asp:Calendar id="myCalendar" runat="server" />
</form>
</body>
</html>
If you save this page in the Learning folder and load it, youd get the output
shown in Figure 4.4.
Figure 4.4. Displaying the default calendar
The Calendar control contains a wide range of properties, methods, and events,
including those listed in Table 4.3.
113
Advanced Controls
Table 4.3. Some of the Calendar controls properties
DescriptionProperty
This property sets the format of the day names. Its possible
values are FirstLetter, FirstTwoLetters, Full, and
DayNameFormat
Short. The default is Short, which displays the three-letter
abbreviation.
This property sets the day of the week that begins each
week in the calendar. By default, the value of this property
FirstDayOfWeek
is determined by your servers region settings, but you can
set this to Sunday or Monday if you want to control it.
Set to CustomText by default, this property can be set to
ShortMonth or FullMonth to control the format of the next
and previous month links.
NextPrevFormat
This property contains a DateTime value that specifies the
highlighted day. Youll use this property a lot to determine
which day the user has selected.
SelectedDate
This property determines whether days, weeks, or months
can be selected; its possible values are Day, DayWeek, Day-
SelectionMode
WeekMonth, and None, and the default is Day. When Day
is selected, a user can only select a day; when DayWeek is
selected, a user can select a day or an entire week; and so
on.
This property controls the text of the link thats displayed
to allow users to select an entire month from the calendar.
SelectMonthText
This property controls the text of the link thats displayed
to allow users to select an entire week from the calendar.
SelectWeekText
If True, this property displays the names of the days of the
week. The default is True.
ShowDayHeader
If True, this property renders the calendar with grid lines.
The default is True.
ShowGridLines
If True, this property displays next/previous month links.
The default is True.
ShowNextPrevMonth
If True, this property displays the calendars title. The de-
fault is False.
ShowTitle
114
Chapter 4: Constructing ASP.NET Web Pages

Get Build Your Own ASP.NET 2.0 Web Site Using C# & VB, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.