我正在尝试更改空文本框的颜色,此表单上有多个文本框,我希望在用户单击提交时突出显示空文本框。在检查所有文本框是否都有值之后,我已经编写了下面的循环,该循环位于我的 btnSubmit 函数中。谁能帮我完成这个循环?
foreach (Control txtbxs in this.Controls)
{
if (txtbxs is TextBox)
{
var TBox = (TextBox)txtbxs;
if (TBox.Text == string.Empty)
{
TBox.ForeColor = Color.Red;
}
}
}
lblTopError.Text = "Please fill in the missing billing information";
pnlTopError.Visible = true;