I want to use the concept of validations using Attributes like [Required]
in webforms. How can I achieve this since this is primarily used in Asp.Net MVC. Basically I want to use ValidateModel
method of Controller
I want to do programmatic validation. Basically I have some XML that I parse using XmlSerializer
but I want to make sure that the string properties do not exceed certain length. So I need to do this programmatically.
Any help is appreciated
why not use the Data Annotations Validator Control?
https://www.nuget.org/packages/DAValidation/
If you want a programmatic validation you can create your own validation logic in your BO or in your Domain class. Create a validate method that returns a list string or any custom class with the errors. Then, show the validation errors to the user.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.