Wrox Programmer Forums
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 September 2nd, 2012, 04:16 AM
Friend of Wrox
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
Old September 2nd, 2012, 06:33 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

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.


Imar Spaanjaars
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!
Old September 2nd, 2012, 09:26 AM
Friend of Wrox
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts

Thanks Imar,
I will dare to do that, and update when I would do.

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

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