Validate Only One Control In Server Side Code On PostBack

J

Joey

Does anyone know how to validate only one certain control in server
side code on postback? Instead of Page.Validate() and Page.IsValid, is
there some functionality equivalent to txtMyTextBox.IsValid...

I could also make it work if I could figure out how to use server side
code to compare a string value against a regular expression string,
with a boolean true/false result.

I need to do this to ensure that my database insert does not insert
corrupt or incomplete data in the event that someone uses a browser
without javascript. The insert is occuring BEFORE the final
postback/validate for the entire page.
 
P

Peter Blum

Every validator has its own Validate() method and IsValid property. Use them
in your post back event method. Call Validate() on each validator attached
to your textbox. Then test all for IsValid=true before saving.

For more on this and other validation ideas, see this article I wrote:
http://aspalliance.com/699.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top