Validate Only One Control In Server Side Code On PostBack

  • Thread starter Thread starter Joey
  • Start date Start date
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.
 
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
 
Back
Top