ValidationSummary breaks validation?

D

da

I've inherited an ASP.net 2.0 (VB.net) application that uses a lot of
GridViews and DetailsViews.

I've ran into an odd issue with validation. We've added some validators to
the INSERT template to validate a field. They include a required field
validator, a Regex validator checking the length of the field, and a custom
validator.

Each is then assigned to the same validation group. We then added a
validationSummary referencing that same group.

Here's the problem:

If we assign the ValidationGroup to the validators, they stop validating. If
w remove the ValidationGroup property, they then work just fine.

3 of us have looked at this and we can't figure out what would be causing
this. Any theories as to what is going on?

-Darrel
 
J

Joern Schou-Rode

If we assign the ValidationGroup to the validators, they stop
validating. If w remove the ValidationGroup property, they then work
just fine.

Did you set the ValidationGroup property of the Button (or whatever is
causing the postback) as well?

I am not sure what the expected behavior should be if the Button does not
specify a ValidationGroup and but all validators do. Should the Button
cause validation across all groups or no validation at all?
 
B

bruce barker

a button with no validation group, will only call validators with no
validation group.

-- bruce (sqlwork.com)
 
D

da

Did you set the ValidationGroup property of the Button (or whatever is
causing the postback) as well?

No! That could be it.

It's actually a EDITITEM template in a DETAILSVIEW control. The postback is
being caused by the rendered INSERT link within the control itself.

-Darrel
 
D

da

No! That could be it.
It's actually a EDITITEM template in a DETAILSVIEW control. The postback
is being caused by the rendered INSERT link within the control itself.


Ah! thanks for the hints! I think we've found what we were missing. Here's
an example of what we had to add:

Protected Sub dvActivityType_ItemInserting(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles
dvActivityType.ItemInserting
' upon inserting item, we need to validate the group of fields in
our view/template
Page.Validate("valActivityType")
' if they are not valid cancel the event
If Not Page.IsValid Then
e.Cancel = True
End If
End Sub
 
J

Jesse Houwing

Hello da,
I've inherited an ASP.net 2.0 (VB.net) application that uses a lot of
GridViews and DetailsViews.

I've ran into an odd issue with validation. We've added some
validators to the INSERT template to validate a field. They include a
required field validator, a Regex validator checking the length of the
field, and a custom validator.

Each is then assigned to the same validation group. We then added a
validationSummary referencing that same group.

Here's the problem:

If we assign the ValidationGroup to the validators, they stop
validating. If w remove the ValidationGroup property, they then work
just fine.

3 of us have looked at this and we can't figure out what would be
causing this. Any theories as to what is going on?

-Darrel


The controls that cause the poastback (say the textboxes and/or the submit
button) need to have the validation group set as well...
 

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,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top