Validator for server control inside user control

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Validator for server control inside user control

    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 Guest

  2. Similar Questions and Discussions

    1. Adding validator to simple server control
      I have some trivial server controls, derived from various WebControls (TextBox, DropDownList, etc). The server control wraps the web control and...
    2. Adding Validator Control at runtime in a Custom Control
      Hi Wim, How do we link the TextBox to this validator control class in runtime ? Could you please tell. Thanks _ Muds. Wim Hollebrandse...
    3. Possible to create a composite control that has a child control that is a validator that validates the composite control itself?
      I am attempting to create a composite control which has a label, followed by an optional error message, followed by two text boxes. I have...
    4. Custom Server Control works on page but not User Control...why?
      I'm developing the DevEdit.NET server control (an online HTML editor - www.devedit.com) but there's an extremely bizarre bug. The control runs fine...
    5. viewstate of the user control inside datagrid...
      Hi there! I have datagrid with template column and I am using the same user control for display (in ItemTemplate) and collect (in EditItemTemplate)...
  3. #2

    Default Re: Validator for server control inside user control

    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 :)
    [url]http://brennan.offwhite.net/blog/[/url]


    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 Guest

  4. #3

    Default Re: Validator for server control inside user control

    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 :)
    > [url]http://brennan.offwhite.net/blog/[/url]
    >
    >
    > 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 Guest

  5. #4

    Default Re: Validator for server control inside user control

    You are correct. It was added to ASP.NET 2.0.

    [url]http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.basevalidator.validation group.aspx[/url]

    You can still create a custom validator.

    Brennan Stehling
    [url]http://brennan.offwhite.net/blog/[/url]

    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 :)
    > > [url]http://brennan.offwhite.net/blog/[/url]
    > >
    > >
    > > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139