custom validator and ControlToValidate in a composite control...

Discussion in 'ASP .Net Building Controls' started by Donal McWeeney, Sep 28, 2004.

  1. The ControlToValidate property is wrecking my head.

    I have a custom composite server control defined as follows:

    internal abstract class MyControlBase : Control, INamingContainer
    {...}

    [ValidationProperty("ValidationValue")]
    internal class MyControl : MyControlBase
    {...}

    MyControl in its CreateChildControls method creates the following:
    - an array of RadioButton control
    - a TextBox
    - a custom validator that I have written.

    If I set the validator ControlToValidate property to the TextBox it works
    fine however it may not be created or rendered. The only thing I can be
    guarnteed of rendering is the array or RadioButtons.

    If I set the validator ControlToValidate to the ID of the instance of
    MyControl I get the following error:

    Unable to find control id 'idMyControl' referenced by the
    'ControlToValidate'
    property of 'idMyControl-rfv'.

    Must ControlToValidate refer to a child of the naming container or can it be
    the control that implements the naming container?

    Is it possible in my custom validator to tell the base validator code not to
    worry about the ControlToValidate property...

    Help!!! Going beserk...

    Thanks

    Donal
    Donal McWeeney, Sep 28, 2004
    #1
    1. Advertising

  2. I think I found half the answer... I can override the ControlPropertiesValid
    method and in that only continue checking the ControlToValidate property if
    its not blank.

    Still wondering about...

    Must ControlToValidate refer to a child of the naming container or can it be
    the control that implements the naming container?
    Donal McWeeney, Sep 29, 2004
    #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. Steven Nagy

    Custom Control needs ControlToValidate

    Steven Nagy, Mar 6, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    592
    MasterGaurav \(www.edujini-labs.com\)
    May 8, 2007
  2. Nathan Sokalski
    Replies:
    1
    Views:
    389
    bruce barker
    May 20, 2008
  3. Nathan Sokalski
    Replies:
    0
    Views:
    347
    Nathan Sokalski
    Mar 8, 2010
  4. Nathan Sokalski

    Accessing the ControlToValidate control in a Validator

    Nathan Sokalski, May 20, 2008, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    806
    bruce barker
    May 20, 2008
  5. Nathan Sokalski

    Accessing the ControlToValidate control in a Validator

    Nathan Sokalski, May 20, 2008, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    164
    bruce barker
    May 20, 2008
Loading...

Share This Page