Thursday, July 5, 2012

Compare system DateTime and user input DateTime in asp.net with c#

protected void Button1_Click(object sender, EventArgs e)
    {
        string dt1 = DateTime.Now.ToString("MM/dd/yyyy");
        string dt2 = TextBox1.Text;
        if (dt1 == dt2)
        {
            TextBox1.Text = "Correct date";
        }
        else TextBox1.Text = "Wrong Date";
    }

No comments:

Post a Comment