asp.net mvc - The value '' is invalid, when data type is int -


i trying display friendly error message on form validation. have property annotations in model class:

[required(errormessage="the number attribute required")] public int level { get; set; } 

it not work, when change data type string, annotation's error message displayed. mean int not supported?

you getting 0 through, why validation appearing not work type - 0 value.

try changing type nullable int (int?) , should fine.


Comments