Unfortunately there is no Prime Number Validation Web control, so we'll have to use a Custom Validator.
The below code shows a simple Web form with a Text Box and a Button, and a Custom Validator validating that the number entered into the Text Box is indeed prime.
One annoying task that most every developer has had to face in the past is form validation.
Since forms are an integral part of dynamic, data-driven Web sites, it is essential that a user's query into a form fit the specified guidelines.
Imagine that you run a Web site for math nerds and that you have a form for users to provide some personal information to improve your knowledge of your site's demographics.
Being math nerds, you may wish to ask them what their favorite prime number is.
Realize that there is no downside to providing client-side validation.
Imagine that you had a series of checkboxes that corresponded to the hobbies sports, reading, and swimming, and you asked the ready to check all hobbies that he enjoyed.NET validation controls is that they all provide client-side validation for uplevel browsers.For example, if you visit the live demo with an uplevel browser you'll note that the Compare Validators exhibit client-side validation (enter a value of "bob" into the Text Box and tab out of it to see what I mean), while the Custom Validator does not (try entering a nonprime number, such as 6, into the Text Box - you are not alerted to the fact that the number you entered is not prime until you submit the form).In such a scenario, you would need to use the Custom Validator to provide the validation logic. NET's validation Web controls contain a required property called With the built-in validation controls, these steps are all performed behind the scenes for us, free of charge.However, when we're using a Custom Validator, we must do this work ourselves.