WorldofASP.NET : ASP.NET Directory, Tutorial, Hosting, and Source Code
You are 1 of 53 users


WorldofASP.NET >> ASP.NET >> Unedited ASP.NET

Custom Validation for DOB Using three dropdownlist

This article is exactly usefull to validate date of Birth having three dropdownlist control.
Published Date : 09 Jul 2008
Author : zafar iqbal
Language : C#
Platform : .NET
Technology : ASP.NET
Views : 5888
Rating : (2 votes so far)



Download CustomDateValidation.zip

Introduction

Sometimes users face problem for DOB Validation so this article is exactly usefull for validate Date of Birth having three dropdownlist control.

Main

A In this project two xml files named DD.xml and MM.xml are used as a datasources to bind Days(DD) and Months(MM) in dropdwnlist control.Years(YYYY) are also bind in dropdwnlist via code and starts from 1950 To Current Year.But user can also change according to their requirement.Functions are created within class file(DataBL.cs) under BusinessLogic folder.Javascripts functions are also used but they are created on the same page.LeapYear Functionality also provided.Download this project to view more information.
Now let us come to start from SourceView.Drag three dropdownlist controls on the page and Name it as a ddlDay,ddlMonth,ddlYear.

Write following code on Page_Load event to bind Days,Months and Years and other two functions(Bind() and BindYr()) are from DataBL.cs i.e from BusinessLogic.
 :

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
hdnCurrentDate.Value = DateTime.Now.ToString("dd-MM-yyyy")
DataBL.Bind(ref ddlDay,"Day");
DataBL.Bind(ref ddlMonth,"Month");
DataBL.BindYr(ref ddlYear);
}
}
public static void Bind(ref DropDownList ddl, string type)
DataSet ds = new DataSet();if (type == "Day")
ds.ReadXml(HttpContext.Current.Server.MapPath"./DD.xml"));
ds.ReadXml(HttpContext.Current.Server.MapPath("./MM.xml"));
ddl.DataSource = ds;
ddl.DataTextField = "name";
ddl.DataValueField = "value";
ddl.DataBind();
}
public static void BindYr(ref DropDownList ddl)
{
for (int i = 1950; i <= DateTime.Now.Year; i++)
{ 
ddl.Items.Add(new ListItem(i.ToString(), i.ToString()));
}
}

Conclusion

It is nice to use custom Validation to validate Date of Birth using three dropdownlist controls

References

Include all the useful links or references that can help users learn about your tutorial

  1. Search Engine
  2. ASP.NET Resources

Download Source Code

Download Source Code

Download Source Code




Other Related and Popular Articles :

Simple asp2 feedback form
A simple way to get user feedback via webpage email.

Basics of XHTML-MP
Basics of XHTML-MP

181
181

Repeater within Repeater
this article is used to show hierarchical data using repeater control.

Introduction to Data Binding in ASP.NET 2.0
This article explains the basic concept about Data Binding in ASP.NET 2.0


Author Profile : zafar iqbal

Hi,
I am zafar iqbal working as a Software Engineer
in Lucknow with SRM TechSol pvt. ltd.

Thanks,
zafar iqbal

Click here to view Author Profile


How would you rate the quality of this content?
Poor Excellent

Comments

Leave New Comments


Article Content copyright by zafar iqbal
Everything else Copyright © by WorldofASP.NET 2010

Category
.NET 3.5
AJAX and ATLAS
ASP.NET
C# Programming
Classic ASP
Enterprise Systems
General .NET
VB.NET Programming
Announcements
Earn Cash by writing an article or review
For more info Click here







Legend : - Within 3 Days - Within 6 Days - Within 9 Days

Home | Add Resources | Sponsored Listings | Advertise with Us | SiteMap 1 | SiteMap 2 | Link To Us | Contact Us
© 2002-2010 Worldofasp.net ASP.NET Directory, Hosting and Tutorials | All rights reserved
Our Partners : ASP.NET Web Hosting | ASP Hosting | ASP.NET Hosting | Phone Card | Calling Card |Stock Investing