I’d like to be able to validate forms server-side (maybe check the database for duplicate entries for a registration form) in addition to client side. I’ve written my validation logic, but I’d like to rerender the view and have the form values the user submitted to be available. Also, I’d like to place an error message and maybe change the color of the font or add an X where a field was invalid. Basically I’m looking to do the equivalent of what formencode and htmlfill does in Python. What would be the best way to do this in C#?
Share
Using ASP.NET, the easiest way would be using a CustomValidator control where you can place your own logic in the validator. A lot of the validation you could probably accomplish with the built-in validator controls like RequiredFieldValidator and CompareValidator.