enter image description hereI create new project with 3 layers one for presentation layer and one for data layer and one for business layer presentation layer contains 3 forms with controls business layer contains class with the method which down what I want is those method is validation for each text box is empty or not but I got the error while running strong text
namespace Teacher_Assistant.BL
{
class Class1
{
public IEnumerable<Control> Controls { get; private set; }
public void checktextboxisempty()
{
foreach (Control c in this.Controls)
{
if ( c is TextBox)
{
TextBox textBox = c as TextBox;
if (textBox.Text == string.Empty)
{
MessageBox.Show("Please fill the boxes");
textBox.BackColor = Color.Red;
break;
}
else
{
textBox.BackColor = Color.White;
}
}
}
}
public void cleanalltextbox()
{
foreach (Control c in this.Controls)
{
if (c is TextBox)
{
TextBox textBox = c as TextBox;
if (textBox.Text != string.Empty)
{
textBox.Clear();
}
}
}
}
}
}