Download presentation
Presentation is loading. Please wait.
Published byJeffrey Hopkins Modified over 8 years ago
1
CSCI 6962: Server-side Desig n and Programming ASP Server Controls
2
Outline Creating complex UI components from toolbox – Checkboxes – Radio buttons – Lists Extracting data from components using code Multiple-select elements and array iteration Dynamic list generation
3
Complex Form Elements Checkboxes – Text property gives label to display next to box Radio buttons Lists – SelectionMode can be Single or Multiple
4
Lists and List Items Edit Items interface to add/edit items in this list – Add items to list – Set Text to appear next to it – Set Value to be passed as parameter if selected
5
Radio Button Lists Create as RadioButtonList to group together Same Edit Items interface
6
ASP vs. HTML
7
Reading CheckBoxes Checkboxes have Checked property (True or False) – Use to add “Monitor” to peripheralLabel – Like string-based conditional output in JSF ( adds line)
8
Reading Radio Buttons/Lists Simplest way to find out which element selected:.Text property – Returns value associated with element (“” if none selected) – Single-select Lists handled same way
9
Reading Multiple-Select Lists List stores array of all options (not just those selected) Use loop to iterate through all items – Listname.Items.Count gives number of items (loop from 0 to Count – 1) – Listname.Items[i] refers to i th item in list – Listname.Items[i].Selected true if i th item selected – Listname.Items[i].Value gives value of i th item
10
Reading Multiple-Select Lists Number of items in SoftwareList Was i th item selected? Get value associated with i th item Keep count of selected items so know whether any selected
11
Dynamic List Generation Adding items to list using code (usually in Page_Load): listname.Items.Add(new ListItem(string)) Example: generating list of months using loop from 1 to 12
12
Dates in ASP Key: Date object – Date.Today used to get current time/date – Date.Today.property gets specific values (Year, Month, Day, Hour, …)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.