Skip to content

Instantly share code, notes, and snippets.

@meataxe
meataxe / CunningValidationSummaryHelper.cs
Last active August 29, 2015 13:59
Updated version of @Html.ValidationSummary to add the validation message source to the list items
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
// Use in views by calling `@Html.CunningValidationSummary(...)` instead of `@Html.ValidationSummary(...)`
// It will give an attribute of `data-valmsg-source` on each list item in the validation summary with a value of the prop the error relates to.
// Then you can use js to scroll to the field in question.
//