Validator for server control inside user control

Discussion in 'ASP .Net Building Controls' started by superman, Sep 5, 2006.

  1. superman

    superman Guest

    Hello,

    I am facing a strange situation and have already spent a lot of time on
    this. I have a user control 'U' that consists of a server/composite control
    'C'. C consists of a textbox 'T' and a datepicker 'D' and implements
    INamingContainer. The user-selected date from D appears in T. The
    validationproperty of C is set to the 'Text' property of T. 'U' also consists
    of a RequiredFieldValidator 'R' that validates C (i.e. The text property of
    T).

    When I use 'U' in an .aspx page, the id of the rendered textbox becomes U:C.
    However, the validator R's ControlToValidate property is set to U_C. Thus,
    the validation never fires since it is referencing to UniqueID instead of the
    ClientID of C.

    What am I missing? Any help is appreciated.

    Thanks,
    superman
    superman, Sep 5, 2006
    #1
    1. Advertising

  2. I would first check the ValidationGroup on every control involved.
    Then run through this with the debugger. What you may have to do is
    use a custom validator which manually checks the value in question.

    Brennan Stehling
    Microsoft Notepad MVP :)
    http://brennan.offwhite.net/blog/


    superman wrote:
    > Hello,
    >
    > I am facing a strange situation and have already spent a lot of time on
    > this. I have a user control 'U' that consists of a server/composite control
    > 'C'. C consists of a textbox 'T' and a datepicker 'D' and implements
    > INamingContainer. The user-selected date from D appears in T. The
    > validationproperty of C is set to the 'Text' property of T. 'U' also consists
    > of a RequiredFieldValidator 'R' that validates C (i.e. The text property of
    > T).
    >
    > When I use 'U' in an .aspx page, the id of the rendered textbox becomes U:C.
    > However, the validator R's ControlToValidate property is set to U_C. Thus,
    > the validation never fires since it is referencing to UniqueID instead of the
    > ClientID of C.
    >
    > What am I missing? Any help is appreciated.
    >
    > Thanks,
    > superman
    Brennan Stehling, Sep 7, 2006
    #2
    1. Advertising

  3. superman

    superman Guest

    Brennan,

    I forgot to mention that I am working with .NET framework v1.1 and not 2.0.
    I don't see any validation group property.

    "Brennan Stehling" wrote:

    > I would first check the ValidationGroup on every control involved.
    > Then run through this with the debugger. What you may have to do is
    > use a custom validator which manually checks the value in question.
    >
    > Brennan Stehling
    > Microsoft Notepad MVP :)
    > http://brennan.offwhite.net/blog/
    >
    >
    > superman wrote:
    > > Hello,
    > >
    > > I am facing a strange situation and have already spent a lot of time on
    > > this. I have a user control 'U' that consists of a server/composite control
    > > 'C'. C consists of a textbox 'T' and a datepicker 'D' and implements
    > > INamingContainer. The user-selected date from D appears in T. The
    > > validationproperty of C is set to the 'Text' property of T. 'U' also consists
    > > of a RequiredFieldValidator 'R' that validates C (i.e. The text property of
    > > T).
    > >
    > > When I use 'U' in an .aspx page, the id of the rendered textbox becomes U:C.
    > > However, the validator R's ControlToValidate property is set to U_C. Thus,
    > > the validation never fires since it is referencing to UniqueID instead of the
    > > ClientID of C.
    > >
    > > What am I missing? Any help is appreciated.
    > >
    > > Thanks,
    > > superman

    >
    >
    superman, Sep 7, 2006
    #3
  4. You are correct. It was added to ASP.NET 2.0.

    http://msdn2.microsoft.com/en-us/li...ebcontrols.basevalidator.validationgroup.aspx

    You can still create a custom validator.

    Brennan Stehling
    http://brennan.offwhite.net/blog/

    superman wrote:
    > Brennan,
    >
    > I forgot to mention that I am working with .NET framework v1.1 and not 2.0.
    > I don't see any validation group property.
    >
    > "Brennan Stehling" wrote:
    >
    > > I would first check the ValidationGroup on every control involved.
    > > Then run through this with the debugger. What you may have to do is
    > > use a custom validator which manually checks the value in question.
    > >
    > > Brennan Stehling
    > > Microsoft Notepad MVP :)
    > > http://brennan.offwhite.net/blog/
    > >
    > >
    > > superman wrote:
    > > > Hello,
    > > >
    > > > I am facing a strange situation and have already spent a lot of time on
    > > > this. I have a user control 'U' that consists of a server/composite control
    > > > 'C'. C consists of a textbox 'T' and a datepicker 'D' and implements
    > > > INamingContainer. The user-selected date from D appears in T. The
    > > > validationproperty of C is set to the 'Text' property of T. 'U' also consists
    > > > of a RequiredFieldValidator 'R' that validates C (i.e. The text property of
    > > > T).
    > > >
    > > > When I use 'U' in an .aspx page, the id of the rendered textbox becomes U:C.
    > > > However, the validator R's ControlToValidate property is set to U_C. Thus,
    > > > the validation never fires since it is referencing to UniqueID instead of the
    > > > ClientID of C.
    > > >
    > > > What am I missing? Any help is appreciated.
    > > >
    > > > Thanks,
    > > > superman

    > >
    > >
    Brennan Stehling, Sep 7, 2006
    #4
    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. Leeor Chernov
    Replies:
    2
    Views:
    787
    Leeor Chernov
    Oct 16, 2005
  2. =?Utf-8?B?c3VwZXJtYW4=?=

    Validator for server control inside a user control.

    =?Utf-8?B?c3VwZXJtYW4=?=, Sep 4, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    479
    =?Utf-8?B?c3VwZXJtYW4=?=
    Sep 4, 2006
  3. Roman
    Replies:
    2
    Views:
    259
    Roman
    Jan 4, 2005
  4. superman

    Validator for server control inside user control

    superman, Sep 5, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    132
    superman
    Sep 5, 2006
  5. Kiran More
    Replies:
    2
    Views:
    313
    Kiran More
    Nov 14, 2006
Loading...

Share This Page