i have two date textbox how to validation for first texbox date not less then second texbox date

Posted by Venky.Net under C# on 9/15/2012 | Points: 10 | Views : 2014 | Status : [Member] | Replies : 2
hi
i have two date textbox how to validation for first texbox date not greater then second texbox value how to validate using c# code.that time show the alert message




Responses

Posted by: Jasminpatel on: 9/15/2012 [Member] Starter | Points: 25

Up
0
Down


if (DateTime.Compare(DateTime.Parse(fromdate.ToString()), DateTime.Parse(todate.ToString())) == 1)

{
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('To Date Should Be Grater Than The From Date')", true);
return;
}


Hope it's help you.
Thank you.



jasmin patel

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
Try this code
DateTime startDate = Convert.ToDateTime(SelectionStartDateTextBox.Text);
DateTime endDate = Convert.ToDateTime(SelectionEndDateTextBox.Text);

if (endDate < startDate)
{
args.IsValid = false;
}


Thanks & Regards
Hari

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response