Question: This program contains a text box where a user can enter a birth date and then click a Verify button, which determines whether the user

This program contains a text box where a user can enter a birth date and then click a Verify button, which determines whether the user is 21 or older. The program has several problems that prevent it from working successfully. Find and debug the errors.

(file) Default.aspx

Enter your birth date: runat="server" ErrorMessage="**"> runat="server" ErrorMessage="Must be in the form mm/dd/yyyy" ValidationExpression="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" ControlToValidate="birthDate" />

ID="validationResult" runat="server" />

(File) Default.aspx.cs

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {

} protected void Button1_Click(object sender, EventArgs e) { double age = Math.Round(System.DateTime.Now.Subtract(birthDate.Text).TotalDays * 365.25, 2); if age

This program contains a text box where a user can enter a

Default.aspx cs Default.aspx" 1 Page Language AutoEventwireup-"true" Code Default.aspx.cs Inherits Default html PUBLIC //W3C//DTD XHTML 1.0 Transitional/ /EN DOCTYPE 4 E 7

11

Enter your birth date: Kasp TextBox ID birthDate runat "server" /> Kasp Required Fieldvalidator ID-"date Validator 13 runat- server ErrorMessage Kasp :RegularExpressionvalidator runat. server" Error Message "Must be in the form mm/dd/yyyy ValidationExpression 0E1-9 11012 12 3001]) (19 20) VdVd 15 16 ControlToValidate birthDate />

17

kasp Button ID Button1 runat Server Text- verify Age" onclick-"Button Click Kasp:Literal 18 ID. validationResult runat. Server />

19

21 22 23

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!