i'm using this code for date chking. the problem is tht if update button is clicked the date and time is getting displayed and if i change the time error is coming as failed to convert datetime to int. Please help
protected void Txtdoj_TextChanged(object sender, EventArgs e)
{
if ((Txtdob.Text != "") && (Txtdoj.Text != ""))
{
DateTime dt1 = Convert.ToDateTime(Txtdob.Text).Date;
DateTime dt2 = Convert.ToDateTime(Txtdoj.Text).Date;
int result = DateTime.Compare(dt1, dt2);
string srtvalue;
DateTime dt3 = System.DateTime.Now.Date;
int res = DateTime.Compare(dt1, dt3);
int resl = DateTime.Compare(dt2, dt3);
if (dt1==dt3 || dt2==dt3)
{
lbmsg.Text =
"both dates should be less than current date ";
}
else
{
if (result > 0)
{
// srtvalue = "is earlier than";
lbmsg.Text =
"DOB must be less than DOJ";
Txtdob.Focus();
Txtdob.Text =
"";
Txtdoj.Text =
"";
}
else if (result == 0)
{
lbmsg.Text =
"DOJ should be > than DOB";
}
else if ((res < 0) || (resl < 0))
{
}
else
{
//srtvalue = "is later than";
lbmsg.Text =
"";
}
}
}
else
{
lbdob.Visible =
true;
lbdob.Text =
"Enter date of birth";
}
}