Validation Controls

D

dotpro2008

I have creates a webform with multiple textboxes and associted them with some
validation controls (like requiredfieldvalidator).

There is command button also. There is some code written in the click event
of the the button. I want that when someclicks that button then the code
should only execute if the all the textboxes are validation.

Right now what is happening is the even though validation summary shows that
textboxes are not validated (e.g. missing required values) but still the
click events triggers.

What statement should I write in click event of button so that it can only
run the code when all the fields are validated.

Thanks,
 
N

Nathan Sokalski

Use the following:

If Me.IsValid Then
YOURCODE
End If

The above code is in VB.NET, but would use the same property (IsValid) for
C# or any other .NET language as well. Also, if you are using the
ValidationGroup property, make sure it is the same for the Button you are
clicking and the Validators you need validated. If this does not help, post
your code so that we can see exactly what you are doing. Good Luck!
 

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,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top