/// <summary> /// Creates LabelFor + ValueFor + ValidationMessageFor, wrapped in two sets of div's to which you can assign custom classes /// </summary> public static MvcHtmlString DisplayPairFor <TModel, TValue>(this HtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, String labelCssClass = null, String valueCssClass = null) { var model = new LabelEditorPair(); model.LabelHtml = html.LabelFor(expression); model.LabelCssClass = labelCssClass; model.EditorHtml = html.NaValueFor(expression); model.EditorCssClass = valueCssClass; return(html.Partial(MVC.Shared.Views.LabelAndValue, model)); }
/// <summary> /// Creates LabelFor + EditorFor + ValidationMessageFor, wrapped in two sets of div's to which you can assign custom classes /// </summary> private static MvcHtmlString EditPairFor <TModel, TValue>(this HtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, bool validate, String labelCssClass = null, String valueCssClass = null) { var model = new LabelEditorPair(); model.LabelHtml = html.LabelFor(expression); model.LabelCssClass = labelCssClass; model.EditorHtml = html.EditorFor(expression); model.EditorCssClass = valueCssClass; if (validate) { model.ValidationHtml = html.ValidationMessageFor(expression); } return(html.Partial(MVC.Shared.Views.LabelAndEditor, model)); }