I had to expand consolidated validation extensions in another project of mine to deal with more than one form per page.
Although this is different, you can create your own extension method ...
namespace System.Web.Mvc { public static class ViewExtensions { public static string MyValidationSummary(this HtmlHelper html, string validationMessage) { if (!html.ViewData.ModelState.IsValid) { return "<div class=\"validation-summary\">" + html.ValidationSummary(validationMessage) + "</div>" } return ""; } } }
Then just call
<%= Html.MyValidationSummary( "Login was unsuccessful. Please correct the errors and try again.") %>
HTHS, Charles
Charlino May 28 '09 at 5:19 a.m. 2009-05-28 05:19
source share