Custom ValidationSummary control with multiple validationgroups in

I used same logic as described in my previous post.
I made Validate method in custom validationsummary control

public void Validate()
foreach (string str in this.ValidationGroup.Split(new char[]{',',';'}))

protected void ChkControl(string groupName)
foreach (IValidator i in Page.GetValidators(groupName))
if (!i.IsValid)
DummyValidator dv = new DummyValidator(i.ErrorMessage);

ChkControl method creates dummy invalid validators and add them with no validationgroup.

How to use this custom control:
First add it in the toolbox and drag it in your page. Define comma separated multiple validationgroups.
Note: it is based on server side validation so set submit button “Causes validation” property false
And on button click event, call “customcontrolID.Validate()” instead of “Page.validate()” . It uses null validation group so null validationgroup validators are also validated.

Click following to download source code.

Don't forget to say thanks if it helps. :)

No comments:

Post a Comment