Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2015, 12:56 PM
Friend of Wrox
 
Join Date: Mar 2011
Posts: 126
Thanks: 39
Thanked 2 Times in 2 Posts
Default Re-Using RegularExpressionValidator for multiple Controls

Hello:

I created a RegularExpressionValidator to validate phone numbers on my ContactUs form.

I can use the ControlToValidate="" property to specify a single control to apply the phone number validation to. Is it possible to apply the same RegularExpressionValidator to multiple phone number text box controls on this form so that I can avoid re-duplicating code?

Thanks.

Tulsi
 
Old January 6th, 2015, 03:11 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You could define the regular expression in the code behind and then assign it to the ValidationExpression property of each of your controls.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
Tulsi (January 15th, 2015)
 
Old January 15th, 2015, 01:40 PM
Friend of Wrox
 
Join Date: Mar 2011
Posts: 126
Thanks: 39
Thanked 2 Times in 2 Posts
Default

Thank you - this works great!

Tulsi





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple View controls shirk99 BOOK: Professional DotNetNuke Module Programming ISBN: 978-0-470-17116-5 0 March 23rd, 2010 12:28 PM
drag and drop multiple controls at runtime ramakishore VB How-To 5 November 2nd, 2006 12:56 PM
multiple constructors for custom controls three BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 0 May 1st, 2006 03:24 PM
Multiple user controls on a page kriskramer General .NET 2 September 14th, 2004 08:42 AM
Multiple controls - grouped william.murray Access 2 August 4th, 2004 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.