Home ] Up ] Syllabus ] Resources ] Tools ] Announcement ] Code ]

Assignment 3: HTML Form Data Processing

Due date:  2007/10/18 submit this assignment online with a link from your default.aspx page to assignment 3.  Delay of each day in your online submission will cost you 0.5 point.

Count for 4 points

  1. Us the registration.htm page (a static HTML page) source code given below and create a registration.aspx page to process the form data submitted via the given registration.htm page.  

Resources:

Requirement:

  1. Check to make sure that the user name is not empty.  (0.5pt)
  2. Check to make sure that the user name and password are the same before you process the form data.  Return an error message properly and ask the user to go back to the previous form page if the user name and password are not the same. (0.5pt)
  3. Process checkbox properly by confirming whether the user has programming experience or not  (0.5pt)
  4. Process radio buttons properly.  Show the color selected in the color name, not the color code. You need to handle the case when none of the options is chosen.  (1 pt)
  5. Handle multiple values (e.g., skills) selected by the user from the "skills" listbox  and list the skill codes of the user in an ordered listing using HTML tag <ol> (1pt)
  6. Display the comment field which has multiple lines of inputs with proper line breaks. (0.5pt)

                Hint: replace(UserComment, Microsoft.VisualBasic.ControlChars.CrLf, "<br>")

 

Submission requirement: 

You need to submit both registration.htm and registration.aspx to your hosting web site.

==

Source Code for the Registration Form -  Registration.htm

==

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

<title>Untitled Page</title>

</head>

<body>

<h1>Registration Form

</h1>

<form action="registration.aspx" method="post">

Name:

<input type="text" name="username" />

<p>

Password:

<input type="password" name="psw" />

</p>

<p>

<input type="checkbox" name="programming" />&nbsp;Have programming experience

</p>

Choose Your Favorite Color<br />

<input type="radio" value="1" name="color" />Red<br />

<input type="radio" value="2" name="color" />Green<br />

<input type="radio" value="3" name="color" />Blue

<p>

Select all your skills (Use CTL key to select more than one item):<p>

<select multiple="multiple" size="3" name="skills">

<option value="db" selected="selected">Database</option>

<option value="wp">Web programming</option>

<option value="sa">Analysis and design</option>

<option value="ec">Electronic Commerce</option>

<option value="ebiz">E-Business System</option>

</select>

</p>

<p>

Your comment:

<br />

</p>

<textarea name="comment" rows="5" cols="44"></textarea>

<p>

<input type="submit" value="Submit" />&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="Reset" />

</p>

</form>

</body>

</html>

 

 

 

==

registration.aspx (Partial code)

==

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

Dim UserName As String

UserName = Request.Params.Get("username")

UserName = UserName.Trim()

If UserName = "" Then

    Label1.Text = "User Name cannot be blank!" & _  

    "<a href='registration.htm'>Back to the reg. page!</a>"

Else

    Label1.Text = "Your name is: " & _

    Request.Params.Get("username")

End If

Dim userComment As String

userComment = Request.Params.Get("comment")

userComment = _

Replace(userComment, Microsoft.VisualBasic.ControlChars.CrLf, "<br>")

Label1.Text &= "<p>" & userComment

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

Form Data Submitted<br />

<br />

<asp:Label ID="Label1" runat="server"></asp:Label>

</div>

</form>

</body>

</html>

==

End of Regisrtation.aspx

==