problems with form validation controls

Discussion in 'ASP .Net' started by merrittr, Jan 30, 2008.

  1. merrittr

    merrittr Guest

    I have the following validator control:


    <asp:RangeValidator ID="RangeValidator1" runat="server"
    ControlToValidate="Purchase_Date"
    ErrorMessage="Invalid Date" MaximumValue="1/01/2222"
    MinimumValue="1/01/1970"></asp:RangeValidator>


    I am trying to use it to validate a textbox in a form view however I
    get the message:


    Unable to find control id 'Purchase_Date' referenced by the
    'ControlToValidate' property of 'RangeValidator1'
    but as far as i can see I have the ID of the textbox?????

    <asp:FormView ID="FormView1" runat="server"
    DataSourceID="SqlDataSource1" DefaultMode="Insert" >

    <asp:TextBox ID="Purchase_Date" runat="server" Text='<%#
    Bind("Purchase_Date", "{0:d}") %>' ></asp:TextBox>


    ..
     
    merrittr, Jan 30, 2008
    #1
    1. Advertising

  2. I haven't seen your entire code, but based on what you have included in your
    posting it looks to me like the reason is because of the fact that the
    TextBox is inside a FormView and the RangeValidator is not. Try doing one of
    the following (I do normally use FormView, but I think one of these might
    work):

    1. Place the RangeValidator inside the FormView.

    OR

    2. Assign the ControlToValidate property programmatically in the Load event.
    You will need to use the FindControl() method and convert it to a TextBox in
    order to do this.

    Hopefully one of these works. Good Luck!
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "merrittr" <> wrote in message
    news:...
    >I have the following validator control:
    >
    >
    > <asp:RangeValidator ID="RangeValidator1" runat="server"
    > ControlToValidate="Purchase_Date"
    > ErrorMessage="Invalid Date" MaximumValue="1/01/2222"
    > MinimumValue="1/01/1970"></asp:RangeValidator>
    >
    >
    > I am trying to use it to validate a textbox in a form view however I
    > get the message:
    >
    >
    > Unable to find control id 'Purchase_Date' referenced by the
    > 'ControlToValidate' property of 'RangeValidator1'
    > but as far as i can see I have the ID of the textbox?????
    >
    > <asp:FormView ID="FormView1" runat="server"
    > DataSourceID="SqlDataSource1" DefaultMode="Insert" >
    >
    > <asp:TextBox ID="Purchase_Date" runat="server" Text='<%#
    > Bind("Purchase_Date", "{0:d}") %>' ></asp:TextBox>
    >
    >
    > .
     
    Nathan Sokalski, Jan 30, 2008
    #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. Colin Basterfield

    Web form validation vs object validation

    Colin Basterfield, Nov 28, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    440
    Tommy
    Nov 29, 2003
  2. Matt
    Replies:
    14
    Views:
    4,170
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  3. =?Utf-8?B?ZGh1cndpdHo=?=
    Replies:
    1
    Views:
    482
    Teemu Keiski
    Apr 10, 2004
  4. baroque Chou
    Replies:
    4
    Views:
    452
    Peter Blum
    Jan 24, 2006
  5. bnp
    Replies:
    4
    Views:
    344
Loading...

Share This Page