silverlight: Validation

本文探讨了Silverlight 3中新增的数据验证功能,并通过示例代码展示了如何使用正则表达式进行属性验证。针对整型属性在输入字符串时的错误处理问题,提出了将属性类型改为字符串类型的解决方案。

.Problem

I take a look the silverlight toolkit ,I found the silverlight 3 have new data validation function.

it is very good function,It support regularExpression in attribute .

Like this:

 

 

 

But I found one problem.

you can take a look my code careful , Age property is Integer .

when I input the data is string ,for example "dddd" ,it don't throw my define the error message, 

It throw the message is "input is not correct format" ,I don't know this reason.

 

Bu I think careful ,it maybe is correct. because I input is string ,C# level will auto throw the error message.

Don't go into my define error message.

 

 

If you input the integer more than two length, it will throw my define the error message.

 

.Solution

you can define the age is string type , It will fixed this problem.

you can follow your state to decide to what to do.

I only advise you to change string type.

 

 

sample code:

 

Person.cs

 

 

views

 

 

code-behind

 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

田猿笔记

写文章不容易,希望大家小小打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值