Ch 17 Storing Basic User Data in the Profile
All going good again, but when I come to add the date to the date of birth text box, the validator says it is wrong? How come?
Code behind:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class UserProfile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FirstName.Text = Profile.FirstName;
LastName.Text = Profile.LastName;
DateOfBirth.Text = Profile.DateOfBirth.ToShortDateString();
Bio.Text = Profile.Bio;
}
}
protected void SaveButton_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
Profile.FirstName = FirstName.Text;
Profile.LastName = LastName.Text;
Profile.DateOfBirth = DateTime.Parse(DateOfBirth.Text);
Profile.Bio = Bio.Text;
}
}
}