开发者

Is there any baked in validation classes in C#?

开发者 https://www.devze.com 2022-12-08 21:29 出处:网络
I want to do simple things anyone in my web app like Checker.Email(string) which would return true or false after doing some regex or something. But I don\'t want to make this whole thi开发者_运维百科

I want to do simple things anyone in my web app like Checker.Email(string) which would return true or false after doing some regex or something. But I don't want to make this whole thi开发者_运维百科ng myself if one already exists...


If you are using ASP.NET then I'd look at the RegularExpressionValidator that's one of the standard .Net Framework controls. Then grab an email regex from www.regexlib.com.


If you're using webforms, there are several ValidationControls you can place on the from, and a slew of third-party controls that use the same system (Inherit BaseValidator or CustomValidator).


You can use Data Annotations. There is a little tutorial at asp.net/mvc. There's also a DataType attribute that will validate an email for you. If use this method, there's xVal by Steve Sanderson which really makes client/server side validation pretty simple.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号