private static StringBuilder AddIntroductionText(string introductionblock, BaseStyleSettings style) { StringBuilder builder = new StringBuilder(); if (!string.IsNullOrWhiteSpace(introductionblock)) { builder.AppendFormat("<div class=\"{0} {1} \">", style.IntroductionBlockClass, style.IntroductionBlockEmphasisClass); builder.Append(introductionblock); builder.Append("</div>"); } return(builder); }
private static StringBuilder AddModelErrors(this HtmlHelper helper, bool showModelErrors, BaseStyleSettings style) { StringBuilder builder = new StringBuilder(); bool alternativestyle = false; if (showModelErrors && !helper.ViewData.ModelState.IsValid) { builder.AppendFormat("<ul class=\"{0}\">", style.DefaultModelErrorGroupClass); foreach (string key in helper.ViewData.ModelState.Keys) { if (key != "") { foreach (ModelError error in helper.ViewData.ModelState[key].Errors) { builder.AppendFormat("<li class=\"{0} {1}\">{2}</li>", style.DefaultModelErrorBaseItemClass, alternativestyle ? style.DefaultModelErrorItemClass : style.DefaultModelErrorItemAltClass, error.ErrorMessage); alternativestyle = !alternativestyle; } } } builder.Append("</ul>"); foreach (string key in helper.ViewData.ModelState.Keys) { if (key == "") { builder.AppendFormat("<div class=\"{0} {1}\">", style.AdditionalModelErrorGroupClass, style.AdditionalModelErrorGroupEmphasis); foreach (ModelError error in helper.ViewData.ModelState[key].Errors) { builder.AppendFormat("<p>{0}</p>", !string.IsNullOrWhiteSpace(error.ErrorMessage) ? error.ErrorMessage : error.Exception.Message); } builder.Append("</div>"); } } } return(builder); }
private static StringBuilder AddModelErrors(this HtmlHelper helper, bool showModelErrors, BaseStyleSettings style) { StringBuilder builder = new StringBuilder(); bool alternativestyle = false; if (showModelErrors && !helper.ViewData.ModelState.IsValid) { builder.AppendFormat("<ul class=\"{0}\">", style.DefaultModelErrorGroupClass); foreach (string key in helper.ViewData.ModelState.Keys) { if (key != "") { foreach (ModelError error in helper.ViewData.ModelState[key].Errors) { builder.AppendFormat("<li class=\"{0} {1}\">{2}</li>", style.DefaultModelErrorBaseItemClass, alternativestyle ? style.DefaultModelErrorItemClass : style.DefaultModelErrorItemAltClass, !string.IsNullOrWhiteSpace(error.ErrorMessage) ? error.ErrorMessage : error.Exception.Message); alternativestyle = !alternativestyle; } } } builder.Append("</ul>"); foreach (string key in helper.ViewData.ModelState.Keys) { if (key == "") { builder.AppendFormat("<div class=\"{0} {1}\">", style.AdditionalModelErrorGroupClass, style.AdditionalModelErrorGroupEmphasis); builder.Append("<strong>The following general errors have occurred:</strong>"); builder.Append("<hr/>"); foreach (ModelError error in helper.ViewData.ModelState[key].Errors) { builder.AppendFormat("<p>{0}</p>", !string.IsNullOrWhiteSpace(error.ErrorMessage) ? error.ErrorMessage : error.Exception.Message); } builder.Append("</div>"); } } } else { //builder.AppendFormat("<ul class=\"{0}\">", style.DefaultModelErrorGroupClass); //builder.Append("</ul>"); } return builder; }
private static StringBuilder AddIntroductionText(string introductionblock, BaseStyleSettings style) { StringBuilder builder = new StringBuilder(); if (!string.IsNullOrWhiteSpace(introductionblock)) { builder.AppendFormat("<div class=\"{0} {1} \">", style.IntroductionBlockClass, style.IntroductionBlockEmphasisClass); builder.Append(introductionblock); builder.Append("</div>"); } return builder; }