How to check if the text box is empty in C#?? I have to display an error box if the textbox is empty. I am trying this way,but no results. Thank you for the help.
private void Save_Click(obje ct sender, EventArgs e)
{
if (textBox1.Text == String.Empty)
{
errortextBox2.V isible = true;
errorgroupBox2. Visible = true;
errortextBox3.V isible = true;
errorbutton1.Vi sible = true;
}
else
{
string itemToAdd = textBox1.Text;
listBox1.Items. Add(itemToAdd);
}
}
private void Save_Click(obje ct sender, EventArgs e)
{
if (textBox1.Text == String.Empty)
{
errortextBox2.V isible = true;
errorgroupBox2. Visible = true;
errortextBox3.V isible = true;
errorbutton1.Vi sible = true;
}
else
{
string itemToAdd = textBox1.Text;
listBox1.Items. Add(itemToAdd);
}
}
Comment