Showing posts with label valid date. Show all posts
Showing posts with label valid date. Show all posts

Check whether date is valid or not

Tuesday, June 29, 2010

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ApplyNow : System.Web.UI.Page
{
    private String dob;

protected void btn_applyNow_Click(object sender, EventArgs e)
    {
        if (getDob())
        {
            if (isAvailable(txt_emailAddress.Text))
                insertStudent();

            else
                lbl_error.Text = "Email already exists";
        }

        else
        {
            lbl_error.Text = "Please enter valid date";
        }
    }

private bool getDob()
    {
        dob = ddl_month.SelectedValue + " " + ddl_day.SelectedValue + ", " + 
        ddl_year.SelectedValue;

        try
        {
            DateTime.Parse(dob);
            return true;
        }

        catch
        {
            return false;
        }
    }

 private void insertStudent()
    {
         //coding    
    }
 }

**************************LINKS******************************

I have created a new better blog:

My Youtube channel:

**************************LINKS******************************