Wednesday, April 19, 2006

Convert String to Date and check Date Validation on Server side in C#.Net.

Convert String to Date and check Date Validation on Server side in C#.Net.

There are lots of functions available in client side for date validation.
Sometime server side date validation function require
It’s very simple but require much time to right. (C#.Net)

SupportedDateFormats : It is a customise function where you can refer the date format whatever you want.

ConvertStringToDate : This will return True or Flase based on date format supported. And give converted Date from String.

public static bool ConvertStringToDate(string dateString, ref DateTime resultDate)
resultDate = DateTime.ParseExact(
return true;
return false;

//This is custom defined format function you can add more date format as per your requirement
like "dd/MM/YYYY", etc in the allFormats array
private static string[] SupportedDateFormats()
string[] allFormats = new string[] {
return allFormats;

// Now you can use this function in your code like this
private void button1_Click(object sender, EventArgs e)
DateTime dtTemp;
dtTemp =DateTime.Today.Date;
lblIsvalidDate.Text =
ref dtTemp
lblCovertedDate = dtTemp.ToString();

If you want this code in VB.Net I would like to tell you very good site that will


eaie6xgs80vpvi said...

Get any Desired College Degree, In less then 2 weeks.

Call this number now 24 hours a day 7 days a week (413) 208-3069

Get these Degrees NOW!!!

"BA", "BSc", "MA", "MSc", "MBA", "PHD",

Get everything within 2 weeks.
100% verifiable, this is a real deal

Act now you owe it to your future.

(413) 208-3069 call now 24 hours a day, 7 days a week.

NRPS said...

I love your code mate Keep up the good work

suda said...

good work

hari said...

it looks very easy & good example and keep it up...

Anonymous said...

miley cyrus nude [url=]miley cyrus nude[/url] miley cyrus nude [url=]miley cyrus nude[/url]

Anonymous said...

Amiable fill someone in on and this enter helped me alot in my college assignement. Thank you on your information.