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

153

被折叠的 条评论
为什么被折叠?



