Adding validators to CompositeControl

Discussion in 'ASP .Net' started by Mantorok, Jun 15, 2006.

  1. Mantorok

    Mantorok Guest

    Hi all

    I finally got around to creating some WebControl classes, however I want to
    add some validation to my custom control, it's a descendant of
    CompositeControl.

    I get the exception: Unable to find control id 'txtForename' referenced by
    the 'ControlToValidate' property of 'valType'

    Here is how I'm creating the validtor(s):

    protected override void CreateChildControls()

    {

    // Create the custom validator

    CustomValidator customVal = new CustomValidator();

    customVal.ID = ID_CUSTOMVAL;

    customVal.ServerValidate += new
    ServerValidateEventHandler(validator_ServerValidate);

    customVal.Text = TEXT_VALIDATOR;

    Controls.Add(customVal);

    // Create the compare validator

    CompareValidator typeVal = new CompareValidator();

    typeVal.ID = ID_TYPEVAL;

    typeVal.Operator = ValidationCompareOperator.DataTypeCheck;

    typeVal.Text = TEXT_VALIDATOR;

    typeVal.ControlToValidate = ID;

    Controls.Add(typeVal);

    base.CreateChildControls();

    }


    Any ideas?

    Thanks
    Kev
     
    Mantorok, Jun 15, 2006
    #1
    1. Advertising

  2. Mantorok

    Mantorok Guest

    Oh, hang on, I think I see the problem.

    Kev

    "Mantorok" <> wrote in message
    news:e6r5pe$gun$...
    > Hi all
    >
    > I finally got around to creating some WebControl classes, however I want
    > to add some validation to my custom control, it's a descendant of
    > CompositeControl.
    >
    > I get the exception: Unable to find control id 'txtForename' referenced by
    > the 'ControlToValidate' property of 'valType'
    >
    > Here is how I'm creating the validtor(s):
    >
    > protected override void CreateChildControls()
    >
    > {
    >
    > // Create the custom validator
    >
    > CustomValidator customVal = new CustomValidator();
    >
    > customVal.ID = ID_CUSTOMVAL;
    >
    > customVal.ServerValidate += new
    > ServerValidateEventHandler(validator_ServerValidate);
    >
    > customVal.Text = TEXT_VALIDATOR;
    >
    > Controls.Add(customVal);
    >
    > // Create the compare validator
    >
    > CompareValidator typeVal = new CompareValidator();
    >
    > typeVal.ID = ID_TYPEVAL;
    >
    > typeVal.Operator = ValidationCompareOperator.DataTypeCheck;
    >
    > typeVal.Text = TEXT_VALIDATOR;
    >
    > typeVal.ControlToValidate = ID;
    >
    > Controls.Add(typeVal);
    >
    > base.CreateChildControls();
    >
    > }
    >
    >
    > Any ideas?
    >
    > Thanks
    > Kev
    >
     
    Mantorok, Jun 15, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ratman
    Replies:
    0
    Views:
    668
    Ratman
    Sep 14, 2004
  2. Mantorok
    Replies:
    2
    Views:
    1,383
    Mantorok
    Jun 22, 2006
  3. Andrew Clancy
    Replies:
    1
    Views:
    994
  4. Nathan Sokalski
    Replies:
    2
    Views:
    1,128
    Coskun SUNALI [MVP]
    Dec 26, 2007
  5. Nathan Sokalski

    Adding controls to the ItemTemplate of a Repeater in a CompositeControl

    Nathan Sokalski, Dec 24, 2007, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    954
    Coskun SUNALI [MVP]
    Dec 26, 2007
Loading...

Share This Page