public static HtmlTag AddValidationMessage(HtmlTag tag, ModelInfo info) { if (tag.HasChild<ValidationMessageTag>()) return tag; var input = tag.FirstNonHiddenInput(); if (input == null) return tag; var validator = info.ConventionsRegistry().Validation.GenerateTags(info); //input.CreateValidationTag(info); var parent = input.Parent; var res = tag; if (parent == null) { parent = HtmlTag.Placeholder(); parent.Append(tag); res = parent; } var pos = input.PositionAsChild(); validator.RegisterParent(parent); parent.Children.Insert(pos + 1, validator); return res; }
public static HtmlTag AddEditorLabel(HtmlTag tag, ModelInfo info) { if (tag.HasChild<LabelTag>()) return tag; var input = tag.FirstNonHiddenInput(); if (input == null) return tag; var label = info.ConventionsRegistry().Labels.GenerateTags(info); var parent = input.Parent; var res = tag; if (parent == null) { parent = HtmlTag.Placeholder(); parent.Append(tag); res = parent; } var pos = input.PositionAsChild(); if (pos == 0) pos = 1; label.RegisterParent(parent); parent.Children.Insert(pos - 1, label); return res; }