Feed Icon  


  • Bryant Likes
  • Send mail to the author(s) E-mail
  • twitter
  • View Bryant Likes's profile on LinkedIn
  • del.icio.us
Get Microsoft Silverlight
by clicking "Install Microsoft Silverlight" you accept the
Silverlight license agreement

Hosting By

Hot Topics


Open Source Projects



The Insensitive Regular Expression Validator Control

Posted in General at Wednesday, June 30, 2004 9:34 AM Pacific Daylight Time

That is quite the name, but it works pretty much as advertised. I have been doing a lot of Regexing lately to parse t-sql code that people input into my latest intranet application. I figured I could share my regex pattern between the server component and the client validation control, but quickly found out a few things.

  1. The client side component doesn't support comments.
  2. More importantly, the client side component is cAsE SeNsItIvE. Ouch!

So with a little Googling I came accross ConceptDevelopment.NET's InsensitiveRegularExpressionValidator. I copy/pasted the source code into my project and had it almost working pretty quickly. Almost working because I got an exception that told me my ValidationExpression could not be null. Well I was setting my ValidationExpression in the page load event so I knew this wasn't true.

Thankfully I've read Nikhil Kothari's book ASP.Net Server Controls which helped me quickly spot the problem. The ValidationExpression was being stored in a local variable which meant it would be empty on the post back since I was only setting it the first time the page was loaded. Cool. I simply changed it to be stored in the ViewState and everything started working perfectly.

Overall this is a very cool control even if it is insensitive :)

Comments are closed.