public override bool Validate() { bool isValid = base.Validate(); isValid &= FormGridManager.Validate(); isValid &= ValidatePermissions(); return(isValid); }
private void ValidateButton_Click(object sender, EventArgs e) { MultiView.EnsureAllLazyLoadedViews(); foreach (UserControl control in _dataEditControls) { FormGridManager formGridManager = control.FindControl("FormGridManager") as FormGridManager; if (formGridManager != null) { formGridManager.PrepareValidation(); formGridManager.Validate(); } } }
/// <summary> Registers all instances of <see cref="FormGridManager"/>. </summary> /// <param name="parent"> Parent element of the FormGridManager objects. </param> private void PopulateFormGridManagerList(Control parent) { ArgumentUtility.CheckNotNull("parent", parent); // Add all FormGridManager instances for (int i = 0; i < parent.Controls.Count; i++) { Control childControl = (Control)parent.Controls[i]; FormGridManager formGridManager = childControl as FormGridManager; if (formGridManager != null) { _formGridManagers.Add(formGridManager); } bool isChildNamingContainer = childControl is INamingContainer; PopulateFormGridManagerList(childControl); } }
/// <summary> Displays the validation messages for each error. </summary> protected virtual void RenderValidationMessages(HtmlTextWriter writer) { _formGridManagers = new ArrayList(); PopulateFormGridManagerList(NamingContainer); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Table); for (int idxFormGridManagers = 0; idxFormGridManagers < _formGridManagers.Count; idxFormGridManagers++) { FormGridManager formGridManager = (FormGridManager)_formGridManagers[idxFormGridManagers]; ValidationError[] validationErrors = formGridManager.GetValidationErrors(); // Get validation messages for (int idxErrors = 0; idxErrors < validationErrors.Length; idxErrors++) { ValidationError validationError = (ValidationError)validationErrors[idxErrors]; if (validationError == null) { continue; } writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (validationError.Labels != null) { writer.AddStyleAttribute("padding-right", "0.3em"); writer.RenderBeginTag(HtmlTextWriterTag.Td); for (int idxErrorLabels = 0; idxErrorLabels < validationError.Labels.Count; idxErrorLabels++) { Control control = (Control)validationError.Labels[idxErrorLabels]; string text = string.Empty; if (control is SmartLabel) { text = ((SmartLabel)control).GetText(); } else if (control is FormGridLabel) { text = ((FormGridLabel)control).Text; } else if (control is Label) { text = ((Label)control).Text; } else if (control is LiteralControl) { text = ((LiteralControl)control).Text; } text = text ?? string.Empty; // Do not HTML enocde. writer.Write(text); } writer.RenderEndTag(); } else { writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } writer.RenderBeginTag(HtmlTextWriterTag.Td); validationError.ToHyperLink(CssClassValidationMessage).RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); } } writer.RenderEndTag(); }
public IEnumerable <FormGridRowInfo> GetAdditionalRows(EditUserControl dataEditControl, HtmlTable formGrid, FormGridManager formGridManager) { yield return(new FormGridRowInfo( new BocTextValue { ID = "ReadOnlyUserNameField", ReadOnly = true, PropertyIdentifier = "UserName", DataSource = dataEditControl.DataSource }, FormGridRowInfo.RowType.ControlInRowWithLabel, "UserNameField", FormGridRowInfo.RowPosition.BeforeRowWithID)); }
public IEnumerable <String> GetHiddenRows(EditUserControl dataEditControl, HtmlTable formGrid, FormGridManager formGridManager) { return(Enumerable.Empty <string>()); }