Click here to Skip to main content
13,148,214 members (54,624 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 17 Sep 2010

ASP.NET client-side validation against a dynamically loaded list

, 18 Sep 2010
Rate this:
Please Sign up or sign in to vote.
Use RegularExpressionValidator to validate user input against a dynamic list of values.
If you need to validate some user input against a set of allowed values, you can use the RegularExpressionValidator by setting its ValidationExpression as follows:


The '|' symbol delimits the set of allowed values in a regular expression.

If you need to load the list of allowed values from a database, config file or other source, you can do so, and simply set the ValidationExpression property of the RegularExpressionValidator at runtime.

Dim currencyDAL As New CurrencyDAL()
Dim currencies As List(Of String) = currencyDAL.SelectAll()
Dim expression As String = String.Join("|", currencies.ToArray)
currencyValidator.ValidationExpression = expression



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170924.2 | Last Updated 18 Sep 2010
Article Copyright 2010 by Richard A. Dalton
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid