110 likes | 238 Views
CSCI 6962: Server-side Desig n and Programming. ASP Server Controls. Complex Form Elements. Checkboxes Text property gives label to display next to box Radio buttons Lists SelectionMode can be Single or Multiple. Lists and List Items.
E N D
CSCI 6962: Server-side Design and Programming ASP Server Controls
Complex Form Elements • Checkboxes • Text property gives labelto display next to box • Radio buttons • Lists • SelectionMode can beSingle or Multiple
Lists and List Items • Edit Itemsinterface 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
Radio Button Lists • Create as RadioButtonListto group together • Same Edit Itemsinterface
Reading CheckBoxes • Checkboxes have Checked property (True or False) • Use to add “Monitor” to peripheralLabel • Like string-based conditional output in JSF (<br/> adds line)
Reading Radio Buttons/Lists • Simplest way to find out which element selected:.selectedValue property • Returns value associated with element (“” if none selected) • Lists handled same way
Reading Multiple-Select Lists • Can use Selectedproperty to check each item in list • 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 ith item in list • Listname.Items(i).Selected true if ith item selected • Listname.Items(i).Text gives value of ith item
Reading Multiple-Select Lists Number of items in SoftwareList Was ith item selected? Get text assocciated with ith item Keep count of selected items so know whether any selected
Dynamic List Generation • Adding items to list using code (usually in Page_Load):listname.Items.Add(string) • Example: generating list of months using loop from 1 to 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, …)