public void CanReadErrorsFromCrossValidationContainerByDefault() { // containment tree: // // Page : IValidationContainer // - outerVC // - inBetweenControl1 : IValidationContainer // - innerVC Spring.Web.UI.Page page = new Spring.Web.UI.Page(); Spring.Web.UI.UserControl userControl = new Spring.Web.UI.UserControl(); userControl.ID = "userControl"; TestValidationControl innerVC = new TestValidationControl(); userControl.Controls.Add(innerVC); page.Controls.Add(userControl); TestValidationControl outerVC = new TestValidationControl(); page.Controls.Add(outerVC); userControl.ValidationErrors.AddError("provider", new ErrorMessage("msg")); Assert.AreSame(userControl, innerVC.TheValidationContainer); Assert.AreSame(page, outerVC.TheValidationContainer); Assert.AreEqual(1, innerVC.TheValidationContainer.ValidationErrors.GetErrors("provider").Count); Assert.AreEqual(0, outerVC.TheValidationContainer.ValidationErrors.GetErrors("provider").Count); // test local-relative name resolution outerVC.ValidationContainerName = "userControl"; Assert.AreEqual(1, outerVC.TheValidationContainer.ValidationErrors.GetErrors("provider").Count); // test global name resolution outerVC.ValidationContainerName = "::userControl"; Assert.AreEqual(1, outerVC.TheValidationContainer.ValidationErrors.GetErrors("provider").Count); }
public void DoesNotReadErrorsFromCrossValidationContainerByDefault() { // containment tree: // // Page : IValidationContainer // - outerVC // - inBetweenControl1 : IValidationContainer // - innerVC Spring.Web.UI.Page page = new Spring.Web.UI.Page(); Spring.Web.UI.UserControl inBetweenControl1 = new Spring.Web.UI.UserControl(); inBetweenControl1.ID = "InBetweenControl1"; TestValidationControl innerVC = new TestValidationControl(); inBetweenControl1.Controls.Add(innerVC); page.Controls.Add(inBetweenControl1); TestValidationControl outerVC = new TestValidationControl(); page.Controls.Add(outerVC); inBetweenControl1.ValidationErrors.AddError("provider", new ErrorMessage("msg")); Assert.AreSame(inBetweenControl1, innerVC.TheValidationContainer); Assert.AreSame(page, outerVC.TheValidationContainer); Assert.AreEqual(1, innerVC.TheValidationContainer.ValidationErrors.GetErrors("provider").Count); Assert.AreEqual(0, outerVC.TheValidationContainer.ValidationErrors.GetErrors("provider").Count); }
public void ReadsErrorsFromClosestValidationContainerByDefault() { // indirect containment Spring.Web.UI.Page page = new Spring.Web.UI.Page(); TestValidationControl vc = new TestValidationControl(); Spring.Web.UI.UserControl inBetweenControl = new Spring.Web.UI.UserControl(); inBetweenControl.Controls.Add(vc); page.Controls.Add(inBetweenControl); Assert.AreSame(inBetweenControl, vc.TheValidationContainer); }
/// <summary> /// Renders validation errors using specified <see cref="HtmlTextWriter"/>. /// </summary> /// <param name="page">Web form instance.</param> /// <param name="writer">An HTML writer to use.</param> /// <param name="errors">The list of validation errors.</param> public override void RenderErrors(Page page, HtmlTextWriter writer, IList errors) { if (errors != null && errors.Count > 0) { StringBuilder sb = new StringBuilder(); string separator = ""; foreach (string error in errors) { sb.Append(separator).Append(error); separator = "\n"; } writer.AddAttribute(HtmlTextWriterAttribute.Src, page.ImagesRoot + "/" + IconSrc); writer.AddAttribute(HtmlTextWriterAttribute.Title, sb.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); } }
/// <summary> /// Renders validation errors using specified <see cref="HtmlTextWriter"/>. /// </summary> /// <param name="page">Web form instance.</param> /// <param name="writer">An HTML writer to use.</param> /// <param name="errors">The list of validation errors.</param> public override void RenderErrors(Page page, HtmlTextWriter writer, IList <string> errors) { if (errors != null && errors.Count > 0) { if (CssClass != null) { writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass); } writer.RenderBeginTag(HtmlTextWriterTag.Span); foreach (string error in errors) { writer.Write(error); writer.Write(" "); } writer.RenderEndTag(); } }
/// <summary> /// Renders validation errors using specified <see cref="HtmlTextWriter"/>. /// </summary> /// <param name="page">Web form instance.</param> /// <param name="writer">An HTML writer to use.</param> /// <param name="errors">The list of validation errors.</param> public override void RenderErrors(Page page, HtmlTextWriter writer, IList errors) { if (CssClass != null) { writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass); } writer.AddAttribute(HtmlTextWriterAttribute.Id, "ctl00_body_validationSummary"); writer.RenderBeginTag(HtmlTextWriterTag.Div); if (errors != null && errors.Count > 0) { foreach (string error in errors) { writer.WriteLine(error); writer.WriteFullBeginTag("br /"); } } writer.RenderEndTag(); }
/// <summary> /// Renders validation errors using specified <see cref="HtmlTextWriter"/>. /// </summary> /// <param name="page">Web form instance.</param> /// <param name="writer">An HTML writer to use.</param> /// <param name="errors">The list of validation errors.</param> public override void RenderErrors(Page page, HtmlTextWriter writer, IList<string> errors) { if (errors != null && errors.Count > 0) { if (CssClass != null) { writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass); } writer.RenderBeginTag(HtmlTextWriterTag.Span); foreach (string error in errors) { writer.Write(error); writer.Write(" "); } writer.RenderEndTag(); } }
/// <summary> /// Renders validation errors using specified <see cref="HtmlTextWriter"/>. /// </summary> /// <param name="page">Web form instance.</param> /// <param name="writer">An HTML writer to use.</param> /// <param name="errors">The list of validation errors.</param> public abstract void RenderErrors(Page page, HtmlTextWriter writer, IList errors);
public LinkThem(Spring.Data.NHibernate.HibernateTemplate ht, Spring.Web.UI.Page page, Common.Logging.ILog log) { this.ht = ht; this.page = page; this.log = log; }
/// <summary> /// Renders validation errors using specified <see cref="HtmlTextWriter"/>. /// </summary> /// <param name="page">Web form instance.</param> /// <param name="writer">An HTML writer to use.</param> /// <param name="errors">The list of validation errors.</param> public abstract void RenderErrors(Page page, HtmlTextWriter writer, IList <string> errors);