asp.net - Data annotation attributes not working using buddy class metadata in an MVC app -
i have found hints mvc 2 recognises 'buddy class' type of property metadata, data annotation attributes applied 'buddy' metadata class, , metadatatype on actual entity class points buddy class, below. however, below, seems attribute makes difference rendered ui displayname
. why other attributes datatype
, required
, , readonly
not working? i.e. why can enter text in read field? why not error when required field empty? why datatype attribute have no apparent effect? why editorformodel
not include validation messages?
[metadatatype(typeof(customermetadata))] public partial class customer { public class customermetadata { [scaffoldcolumn(false)] public object customerid { get; set; } [displayname("customerno.")] [readonly(true)] [required(allowemptystrings = false, errormessage = "customer no. required.")] public object customerno { get; set; } } }
i find behaviour same whether use explicit labelfor
, textboxfor
each model property, or single editorformodel
whole model.
required
affects validation.readonly
affects binding.
the errormessage
string output when use validationfor()
method.
Comments
Post a Comment