[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 800
  • Last Modified:

Set datetime textbox to string.empty

I have a datetime textbox and a clear button.When user clicks "clear", i want to have that textbox set to blank.My below code doesnt work. Not sure how to do it. I think some default date should be used and compared with but not sure...
private DateTime? JobEndDate
    {
        get
        {


            DateTime? dateValue = null;
            if (!string.IsNullOrEmpty(txtEmployedTo.Text))
                dateValue = Convert.ToDateTime(txtEmployedTo.Text);
            return dateValue;
        }

        set { txtEmployedTo.Text = Convert.ToString(value); }
    }

///*********
JobEndDate = string.Empty; //*** this doesnt work

Open in new window

0
Camillia
Asked:
Camillia
  • 2
1 Solution
 
leonov_alexCommented:
JobEndDate = null
0
 
leonov_alexCommented:
set {
 if (value.HasValue)
  txtEmployedTo.Text = Convert.ToString(value.Value);
 else
    txtEmployedTo.Text = String.Empty;
}

JobEndDate = null
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now