ValidationSummary breaks validation?

  • Thread starter Thread starter da
  • Start date Start date
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
 
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?
 
a button with no validation group, will only call validators with no
validation group.

-- bruce (sqlwork.com)
 
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
 
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
 
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...
 
Back
Top