Inheriting From BaseValidator to Make Custom Validation Controls
For months now, I’ve been desperate for a decent excuse to make a custom ASP.NET server control, so I was secretly pleased today when a CustomValidator originally coded for use on a single page was required elsewhere. It’s surprisingly easy to do, although it took me a while to find a decent example online, which eventually came courtesy of the 4GuysFromRolla. In my particular scenario, I needed to check that the text entered into a TextBox did not equal any of a selection of “banned” strings (which was available via a static property on another class). ...