homework4

In Homework 4, we're asked to create a basic form using ASP.NET server controls (text fields, radio button lists, file uploads, etc.).

The form should have two input buttons: Review and Submit. On clicking the review button, the user should be given a numbered list (ordered list) that contains the field name and associated value for each field in the form. On clicking the submit button, the user should be given a message like: "Thank you for submitting the information."

For more information, read the assignment instructions on Blackboard.

Things you'll need to know...
//"How do I make something happen when the user clicks on a button?"// Add an **onclick** attribute to the server control. The attributes value should be the name of the function you would like run upon being clicked. code format="html4strict"  code

//"How do I access form input field values?"// You can access a field's value by calling its name along with the text (or whichever appropriate) method.

To access a text field ("name" is the name of my input field) : code format="csharp" string customerName = name.Text; code To access a dropdown list's selected item ("state" is the name of my dropdown list): code format="csharp" string customerState = state.SelectedValue; code To access a calendar's selected time ("servicecal" is the name of my calendar): code format="csharp" string customerAppointment = servicecal.SelectedDate.ToShortDateString; code

//"How do I list out selected values of checkboxes?"// You must loop (for loop) through all the checkboxes and store which is selected. code format="csharp" string customerHeardAboutUs = ""; for (var i = 0; i < hearaboutus.Items.Count; i++) {    if (hearaboutus.Items[i].Selected) {         customerHeardAboutUs = customerHeardAboutUs + hearaboutus.Items[i].Text; customerHeardAboutUs = customerHeardAboutUs + ", "; } } code This loops through all the checkboxes and if a checkbox is selected, its value is appended to a string (customerHeardAboutUs).

//"How do I add items to a numbered list dynamically?"// You must first add a bulleted list server control to your aspx page. Afterwards you can use the following line of code to add an item to it. code format="csharp" formlist.Items.Add(new ListItem("Name: " + customerName)); code "formlist" in this case is the name of my bulleted list control.