modelstate

How to prevent a ModelBinder error in a mandatory fields of a list?

I've got this object created from EntityFramework from my database. [EdmEntityTypeAttribute(NamespaceName="ContactCoreModel", Name="TargetLang")] [Serializable()] [DataContractAttribute(IsReference=true)] public partial class TargetLang : EntityObject { #region Factory Method /// <summary> /// Create a new TargetLang object...

Applying Required Attribute Valiation on a Collection, IEnumberable

Hi, how can I apply Required Attribute like validation to the following without knowing how many elements will be in each collection: public class MyViewPageViewModel { [Required] public List<int> IntCollection { get; set; } [Required] public Dictionary<int, string> IntAndStringAllValueCollection { get; set; } [Required("Val...

How do you validate multi-part models?

I'm working on a really big order form with a bunch of multi-part data that's submitted all at once. I'm using that trick where you render 30-40 item rows in the HTML and allow the user to "show" or "hide" more or less using jQuery. The problem is that while the user may have, say, three rows "showing" and they happen to fill all three ...

Manually adding text to html.ValidationSummary?

I am rather new to mvc2 and when following a writeup on data annotations and such, I came across a bit of code that let me manually add a line of text to the validation summary. I've searched for the last 2 or 3 hours and I've come to the point where I think I'm just searching for the wrong thing. Its not custom validators I'm looking f...

ASP.NET MVC 2 Model Errors with Custom Exceptions

Hi Guys, I have a custom exception class: public class MyException: Exception { public MyException(MyExceptionEnum myError) : base(myError.ToDescription()) { } public MyException(MyExceptionEnum myError, Exception innerException) : base(myError.ToDescription(), innerException) { } } .ToDescription is a extension method on MyExc...