ValidationGroup Not Working in WebControl

81 Views Asked by At

I have an address form WebControl built in a class library that I use in a number of projects within a single solution. I am trying to send in a ValidationGroup and assign it to all the RequiredFieldValidators in that control and it does not work.

Here is the embed on the page...

<supr:SuprAddress ID="iAddress" runat="server" ValidationGroup="frmCheckout" />

I have the public property setup with the WebControl as follows...

private string _validationGroup;
public string ValidationGroup
{
    get
    {
        return _validationGroup;
    }
    set
    {
        _validationGroup = value;
    }
}

NOTE: I have also tried storing this value in ViewState and that did not solve the problem.

And here is a short snippet of the CreateChildControls method...

protected override void CreateChildControls()
{
    txtFirstName = new TextBox() { ID = "txtFirstName", MaxLength = 24 };
    rfvFirstName = new RequiredFieldValidator() { ID = "rfvFirstName", ControlToValidate = txtFirstName.ID, ValidationGroup = this.ValidationGroup };
    // ... add controls, etc...
}

All the control are successfully added and the RequiredFieldValidator is set to validate the textbox, but the validation group is always blank. Any ideas?

0

There are 0 best solutions below