Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 6th, 2015, 12:56 PM
Friend of Wrox
Points: 595, Level: 8
Points: 595, Level: 8 Points: 595, Level: 8 Points: 595, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #2 (permalink)  
Old January 6th, 2015, 03:11 PM
Imar's Avatar
Wrox Author
Points: 72,019, Level: 100
Points: 72,019, Level: 100 Points: 72,019, Level: 100 Points: 72,019, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,075
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
Tulsi (January 15th, 2015)
  #3 (permalink)  
Old January 15th, 2015, 01:40 PM
Friend of Wrox
Points: 595, Level: 8
Points: 595, Level: 8 Points: 595, Level: 8 Points: 595, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 126
Thanks: 39
Thanked 2 Times in 2 Posts
Default

Thank you - this works great!

Tulsi
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.