void IterateControls(Control parent)
{
foreach (Control child in parent.Controls)
{
int exit = 0;
if (child.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox") && child.ID.IndexOf("txt_") == 0)
{
TextBox textbox = (TextBox)child;
if (textbox.Text == "")
{
lblError.Visible = true;
lblError.Text = "Please Answer All Questions";
goto end;
}
string Answer = Convert.ToString(textbox.Text);
int count = CountWords(Answer);
if (count > 500)
{
lblError.Visible = true;
lblError.Text = "An answer should not carry more then 500 words";
exit = 1;
goto end;
}
}
if (child.Controls.Count > 0 && exit!=1)
{
IterateControls(child);
}
}
end: { return; }
}
|