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
| FAQ | Members List | 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 September 2nd, 2012, 04:16 AM
Friend of Wrox
Points: 1,469, Level: 15
Points: 1,469, Level: 15 Points: 1,469, Level: 15 Points: 1,469, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile validation class like css class

Hello all,

In web forms we need to use validation controls at many stages, and in a complete website we have many pages which need validations.

But at every page we have to use those validation controls with full definition. So isn't there a way to use validation controls as we do with css classes, just define once and use anywhere.

for ex, for textbox and ragular expression I want to write code like this

<asp:TextBox ID="TextBox1" runat="server" ValidationClass="Regular(Email)"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" ValidationClass="Regular(ContactNo)"></asp:TextBox>
if it is possible anyhow.

Please tell me if this/or similar method is possible.

Many thanks
Reply With Quote
  #2 (permalink)  
Old September 2nd, 2012, 06:33 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You could build your own custom controls. In this case, you would need a composite control that contains a TextBox and a RegularExpressionValidator. For more details: http://msdn.microsoft.com/en-us/libr...(v=vs.71).aspx

Not necessarily an easy thing to do, but it could be worth it if you have the need for validatable TextBox controls as you described.

Cheers,

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
  #3 (permalink)  
Old September 2nd, 2012, 09:26 AM
Friend of Wrox
Points: 1,469, Level: 15
Points: 1,469, Level: 15 Points: 1,469, Level: 15 Points: 1,469, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Thanks Imar,
I will dare to do that, and update when I would do.
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
CSS class not recognized in ContactForm.ascx avi1 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 October 11th, 2010 06:05 AM
css class Banishah ASP.NET 3.5 Basics 1 August 1st, 2009 03:18 AM
retrieve attribute values from CSS(from class) anujrathi ASP.NET 2.0 Professional 1 May 7th, 2007 01:57 PM
CSS Class rupen CSS Cascading Style Sheets 3 April 13th, 2007 05:35 PM
CSS class Attaching NitinJoshi General .NET 1 January 24th, 2005 04:14 AM



All times are GMT -4. The time now is 11:52 PM.


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