MVC校验_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > MVC校验

MVC校验

 2014/10/23 21:32:15  请叫我Jack  程序员俱乐部  我要评论(0)
  • 摘要:首先Model里面需要写好校验标签,我的数据库中有个tblUserInfo表,其中有Id,UserName,,Age三个列,Id自动增长Model添加UserInfoClass,在UserName和Age属性上方写上校验标签,需要usingSystem.ComponentModel.DataAnnotations;前台校验后台校验只需要添加一句话if(ModelState.IsValid)//判断是否校验成功
  • 标签:MVC

首先Model里面需要写好校验标签,

我的数据库中有个tblUserInfo表,其中有Id,UserName,,Age三个列,Id自动增长

Model添加UserInfo Class,在UserName和Age属性上方写上校验标签,需要using System.ComponentModel.DataAnnotations;

前台校验

QQ4iJ8OTsBIYR4aaTCQghxJlJhIYQ4E6nwKh6Px+PxODuLQ3nBXRZinPkq/MePjz9+fETj0abBiCPTKx6/424l/UzM6i685l4LMcKSWhjI4lzFTJEKDdTkFBU+7LgNBpIKC5FFKuwjFe5DKixEFlaF935C2VXAy27/oRoBZqCDAabvq1E+pMpEvYi5HQk3K/cgR8mTyRwWSCosRJZELVy9gbOD7mrThhFNV9n7XO1UalKuMkJDSrBNjFnOknqOxotuCbEQKa6uwtnEQPQjVZgxiw5XVLcyQUGs6FvI3ECSYCGySIV9DlDhLRDHyJIJ2gy3OpBUWIgs01SY7AMc05EgcwYcWQtHg93JMz5XBNqkwkLkyamwe+pmH6kWonNBzBmh6BwRSKkK7TphfEbXC+PriF0/TRtwPG2e7mD3OcAVgXgzIcROZy0smjTFeko39jDVIz94pMJCZElfqbY0m1dDR1UIoftICCHEmUiFhRDiTKTCQghxJlJhcQM+fn4Hq037QbPsFN7m4+d3++hz67rCDq/Gt19fZ0359uvr/qhWwZQpKXWQVuHUvRReBx2QKeza5I5Hq5EfMly56obuELh9k2vT3EEm2z7L1O7Yp8N9nTc1gRS4asRVzEpPI3ndl3cVbsa9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Bzm66yWBHEj8qyXHAdWufNfBixBkiFxUW4yv2FcbeBGSE/DxjpPF6FVwySuc2Cv+Ahum4hchX1o7f4w6CZbeoDWIilLL+/cDnXPWlmT7tFfYa+04BROfww2PFylh0sx4Hlvrz/tbFwoGZ07DManAt5jQQ23rxCmKmLScsdqbC4Duf8du7ca9o+8TvtcUjZ68IoYLMjEXV7+bjdhfABH1RCuJxwHwm3RBWzkJoIcS90Nx8hhDgTqbAQQpyJVFgIIc7kCBV+f38/bJYQQtyL81X4/XfArPeYJXkLIcR6circoXpPY3JKU4VJSyGEuAsJFe4QvuwUqbAQ4tVYqMK7jV2ozNSREEK8LJ19YabV6xpb0YxcqRYWQrwCPSqcVb2mZJPjUmEhxOcjrcIdkscUzupICCFek/Q1Eh0x+Fk6OyeEeDX+D1SIn9tw+BvUAAAAAElFTkSuQmCC" alt="" />

WTPi75dBRgBnIiMAKNaM+NtlkBHAmcgIAApj3gJQGDsfgEJGAFDICAAKGQFAISMAKGQEAIWMAKCQEQCU/wNhlDCZC1pd6AAAAABJRU5ErkJggg==" alt="" width="259" height="140" />

后台校验只需要添加一句话if(ModelState.IsValid)//判断是否校验成功

 

上一篇: win8.1弹框 下一篇: 没有下一篇了!
发表评论
用户名: 匿名