Click here to Skip to main content
15,909,747 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am doing a project in asp.net with csharp,in that design page as follows;

Name textbox1
DOB textbox2(calendar image) when i calendar image in that calendar which date is selected that date is diplayed in the textbox2)
Mobile textbox3
Wedding textbox4(calendar image) when i calendar image in that calendar which date is selected that date is diplayed in the textbox4)
Email textbox5


And one insert button.

when i click the insert button suppose user choose both DOB and Wedding Date be the same that time message displays DOB and Wedding date should not be the same.

for that validation how to do in asp.net with csharp.

please help me.please give the code.
Posted
Comments
[no name] 26-Dec-12 1:23am    
No, we won't give you solution.. We can't work out for you like this.. You should try it by yourself.. If you got stuck somewhere, you can certainly come here.. But don't ask directly for code..
-Krunal R.

Hi... i will provide code but remember kurnal's message:

C#
DateTime dtDOB = Convert.ToDateTime(textbox2.Text);
DateTime dtWED = Convert.ToDateTime(textbox4.Text);

if(dtDOB.Day == drWED.Day && dtDOB.Month == drWED.Month && dtDOB.Year == drWED.Year)
{
     // DO NEEDFULL
}

OR

// TIME STAMP MAY CRAETE PROBLEM
if(dtDOB == drWED)
{
     // DO NEEDFULL
}
 
Share this answer
 
v2
Learn about ASP.NET Validation Controls[^]
You can achieve this using CompareValidator Control.
Check out these articles
Validation Controls in ASP.NET[^]
ASP.NET - Validation Controls[^]
 
Share this answer
 
C#
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
   {
       TextBox2.Text = Calendar1.SelectedDate.ToShortDateString();
   }
   protected void Calendar2_SelectionChanged(object sender, EventArgs e)
   {
       TextBox4.Text = Calendar2.SelectedDate.ToShortDateString();
   }
   protected void insert_Click(object sender, EventArgs e)
   {
       string str = TextBox4.Text;
       if (TextBox2.Text.Equals(str))
       {
           Response.Write(@"<script language='javascript'>alert('wedding date and birth date should not be same');</script>");
       }
       else
       {
           //whatever your code is
       }
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900