asp.net| Example | download
(a). Overview and FunctionsTwo methods are used to validate the email format, asp.net the validation controls, and manually write code validation. and use it to simple factory and fitting design patterns, code refactoring technology. Implement custom email address validation and complete the following functions:
Question 11. The Email format is user@server.domain. For example: King.Cheng@hotmail.com or King.Cheng@hotmail.com.cn or King.cheng@hotmail.com.cn.c.d 2. An Email address can have only one @ sign. 3. User name part A) user name is not nullable B) can contain "." Only as a number or letter C). "-" "_" "~" symbol, other sign illegal d) can not start with a special symbol 4. Domain name part A) domain name can only be numbers or letters, cannot use special symbol B domain name or server cannot be empty 5. This mail server can be accessed through DNS, not the WWW server. For example, a Hotmail.com mail server can be accessed, but a Hotmail.com HTTP server is not necessarily a mail server.
Question 2Using regular expressions to refactor Question1, the top 5 does not have to be implemented.
(b). AnswerDownload the code and open the solution: ValidateEmail.sln
Question 1:Project: Validateemail answer to this question
Question 2:Project: Validateemail_refactor answer to this question [reconstructed project]
the class structure after refactoring is as follows:
(iii). Sample code Download
Http://www.cnblogs.com/Files/ChengKing/ManuValidateEmail.rar