protected void btnSave_Click(object sender, EventArgs e) { StringCollection errors = new StringCollection(); if (this.Validate(ref errors)) { this.Save(); // Close window, etc. } else { // Display the validation error(s) to the user UIUtil.DisplayValidationErrorDiv(this.Page, errors); } }
private bool Validate(ref StringCollection errors) { bool blnRetVal = true; if (errors == null) errors = new StringCollection(); // Validate required fields blnRetVal = blnRetVal & UIUtil.Validate_Required([formField], ref errors, "[errorMessage]"); // Other Validation here. return blnRetVal; }