I have 5 textboxes, i would like to obtain total count of all textboxe(s) that has value amongst the 5 textboxes. The total count appears in Label. The following code counts all textboxes in the form. I would appreciate if anyone can help edit it to do as aforementioned. Thank you.
protected void btnGetCount_Click(object sender, EventArgs e)
{
int countTB = 0;
foreach (Control c in form1.Controls) //here is the minor change
{
if (c.GetType() == typeof(TextBox))
{
countTB++;
}
}
Label2.Text=("No of TextBoxes: " + countTB);
}
