Answers for "how to use combo box to find age in c#"

C#
0

how to use combo box to find age in c#

protected void btn_Click(object sender, EventArgs e)
    {
         // here you use your ddl,combobox or etc where age date is inserted
        DateTime dtStart = DateTime.Parse(txtDoB.Text);
        TimeSpan sp = DateTime.Now - dtStart;
        int year = "18";
        int days = 365;
        int total = year * days;

        if (sp.Days < total)
        {

            txtDoB.Text = "Not Valid";
            lblMess.Text = "You can not be under 18 years";
            lblMess.CssClass = "Errr";
            return;
        }
}
Posted by: Guest on August-19-2021

C# Answers by Framework

Browse Popular Code Answers by Language