data-annotation

ASP.NET MVC Model/ViewModel Validation

I have model classes in Linq-to-Sql with partial classes marked with data annotation attributes and a reference to xVal. When I bind a view directly to a model everything works great, both the JS generated by xVal and server side double check. Many of my views don't take input to one specific model, so I am setting up view model cl...

ASP.NET MVC Data Annotations Validation ErrorMessageResourceType

When using Data Annotations Valition, everything works fine until I try to use resources. Here's the error I get: The name 'ErrorMessageResourceType' does not exist in the current context. And the code I used: using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Microsoft.Web.Mvc; namespace Project.Models ...

MVC data annotation layer: where to put the set CurrentUICulture statement?

Hi, I am getting crazy with the localization of an MVC application. After a recent question of mine I have followed this approach: The language is stored in Session["lang"] Each controller inherits from my own BaseController, which overrides OnActionExecuting, and in this method reads the Session and sets CurrentCulture and CurrentUI...

ASP.NET MVC, Linq to SQL Data Annotation Validation

I'm trying implement Data Annotation to my Linq to SQL objects. The .dbml file is generated and I'm not sure how to add data annotation to the objects without touching the generated source code. I tried to add data annotations to the a separate partial class of the object, but its not recognizing it, no Intelli sense either. ...

Date formatting using data annotations for a dataform in Silverlight

This is probably got a simple answer to it, but I am having problems just formatting the date for a dataform field.. <df:DataForm x:Name="Form1" ItemsSource="{Binding Mode=OneWay}" AutoGenerateFields="True" AutoEdit="True" AutoCommit="False" CommitButtonContent="Save" CancelButtonC...

StringLengthAttribute and Localized text

The following code was grabbed from MSDN: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.stringlengthattribute.aspx [MetadataType(typeof(ProductMetadata))] public partial class Product { } public class ProductMetadata { [ScaffoldColumn(true)] [StringLength(4, ErrorMessage = "The ThumbnailPhotoFi...

Is Data Annotations really a good idea for validation?

As I'm learning more and more about ASP.NET MVC the more I am introduced to Data Annotations. Specifically in MVC they are used for validation and this gives me some concerns. The biggest is due to the fact that I like to keep my model as POCOs and as clean as possible. Now what if I have those model classes shared across multiple projec...

Data Annotation and Metadata Types and "Stitching Together Values" (C#)

I'm trying to setup data annotation validation for an object in my model and it has a special need. I have to essentially take some extra properties that I'm adding and combine them to get the value of a real property. For example I have a base object: Task { public DateTime? Due } But my form has the fields of: Task.DueDate Task...