public void Visit(HtmlRadioGroup h) { sb.Append(Tabs(h.Depth)); sb.Append(string.Format("<{0}", h.Tag)); foreach (var a in h.Attributes.Where(a => a.IsSet)) { sb.Append(a); } foreach (var e in h.Events.Where(e => e.IsSet)) { sb.Append(e); } sb.AppendLine(">"); foreach (var c in h.Contents) { Visit(c); } sb.Append(Tabs(h.Depth)); sb.AppendLine(string.Format("</{0}>", h.Tag)); }
public virtual void Visit(FormRadioGroup formRadioGroup, HtmlContainer htmlContainer) { HtmlDiv htmlDiv = verbose ? new HtmlDiv(formRadioGroup.Path) : new HtmlDiv(); htmlDiv.Class.Add("formRadioGroup"); if (!string.IsNullOrWhiteSpace(formRadioGroup.CssClass)) { htmlDiv.Class.AddRange(formRadioGroup.CssClass.Split(' ').Where(s => s != string.Empty)); } if (!string.IsNullOrWhiteSpace(formRadioGroup.Path)) { htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formRadioGroup.Path)); } htmlDiv.Class.Add("formField"); if (initialize) { htmlDiv.Class.Add(formRadioGroup.IsRequired ? "formRequired" : "formOptional"); } else { if (!formRadioGroup.IsRequired || formRadioGroup.HasValue) { htmlDiv.Class.Add("formValid"); } else { htmlDiv.Class.Add(formRadioGroup.IsRequired ? "formNotEntered" : "formOptional"); } } htmlDiv.Hidden.Value = formRadioGroup.IsHidden; htmlContainer.Add(htmlDiv); HtmlRadioGroup htmlRadioGroup = new HtmlRadioGroup(formRadioGroup.Path, verbose, formRadioGroup.Update); htmlRadioGroup.Disabled.Value = formRadioGroup.IsDisabled; if (!initialize && firstInvalidId == null) { if (formRadioGroup.IsRequired && !formRadioGroup.HasValue || !formRadioGroup.IsValid) { firstInvalidId = htmlRadioGroup.Id.Value; } } switch (formRadioGroup.OrderElements) { case OrderElements.LabelMarkInput: AddLabelMark(formRadioGroup, htmlRadioGroup, htmlDiv); htmlDiv.Add(htmlRadioGroup); break; case OrderElements.MarkLabelInput: AddMarkLabel(formRadioGroup, htmlRadioGroup, htmlDiv); htmlDiv.Add(htmlRadioGroup); break; case OrderElements.InputLabelMark: htmlDiv.Add(htmlRadioGroup); AddLabelMark(formRadioGroup, htmlRadioGroup, htmlDiv); break; case OrderElements.InputMarkLabel: htmlDiv.Add(htmlRadioGroup); AddMarkLabel(formRadioGroup, htmlRadioGroup, htmlDiv); break; case OrderElements.LabelInputMark: AddLabel(formRadioGroup, htmlRadioGroup, htmlDiv); htmlDiv.Add(htmlRadioGroup); AddMark(formRadioGroup, htmlRadioGroup, htmlDiv); break; case OrderElements.MarkInputLabel: AddMark(formRadioGroup, htmlRadioGroup, htmlDiv); htmlDiv.Add(htmlRadioGroup); AddLabel(formRadioGroup, htmlRadioGroup, htmlDiv); break; default: case OrderElements.NotSet: break; } foreach (var formRadioButton in formRadioGroup.Content) { Visit(formRadioButton, htmlRadioGroup); } if (initialize) { return; } string message = null; if (formRadioGroup.UseLastMessage) { if (!string.IsNullOrEmpty(formRadioGroup.LastMessage)) { message = formRadioGroup.LastMessage; } } else if (formRadioGroup.IsRequired && !formRadioGroup.HasValue) { message = formRadioGroup.RequiredMessage; } else if (!formRadioGroup.IsValid) { message = formRadioGroup.ValidationMessage; } if (message == null) { return; } HtmlLabel htmlLabelMessage = new HtmlLabel(verbose ? string.Format("{0}{1}", formRadioGroup.Path, "Message") : ""); htmlLabelMessage.Class.Add("formValidationMessage"); htmlLabelMessage.For.Value = htmlRadioGroup.Id.Value; htmlLabelMessage.Add(new HtmlText(message)); htmlDiv.Add(htmlLabelMessage); }