262
Chương 7: ASP.NET và Web Form
if (!Page.IsValid) {
lblCustomSummary.Text = "";
foreach (BaseValidator validator in this.Validators) {
if (!validator.IsValid) {
TextBox invalidControl = (TextBox)
this.FindControl(validator.ControlToValidate);
lblCustomSummary.Text +=
"The page contains the following error: <b>" +
validator.ErrorMessage + "</b>.<br>" +
"The invalid input is: <b>" +
invalidControl.Text + "</b>." + "<br><br>";
}
}
}else {
lblCustomSummary.Text = "Validation succeeded.";
}
}
}