RequiredFieldValidator Question

Discussion in 'ASP .Net Web Controls' started by Randel Bjorkquist, Mar 29, 2005.

  1. Hi all,

    I'm extremly new to building web-applications, C#, and the whole Microsoft
    Visual Studio 2003 .NET IDE, so please bare with me.

    What I have:
    I have a web-application that communicates to an SQL Server. My aspx file
    is on a Windows 2000 Server running IIS. The base of the program is working
    just ducky.

    My problem:
    I'm trying to set the "ControlToValidate" property of a
    "RequiredFieldValidator" at run time and get an exception when my code
    executes. The error is "Unable to find control id
    'System.Web.UI.WebControls.ListBox' referenced by the 'ControlToValidate'
    property of 'rfv_Parts'."

    CODE:
    :
    private void cmd_Submit_Click(object sender, System.EventArgs e){
    rfv_Parts.ControlToValidate = lstbox_Parts.ToString();
    :
    }//END OF "cmd_Submit_Click" METHOD
    :

    Can someone tell me why this isn't working?

    Thanks,

    Randel Bjorkquist
    Randel Bjorkquist, Mar 29, 2005
    #1
    1. Advertising

  2. Randel Bjorkquist

    Matthias S. Guest

    I'd try:

    rfv_Parts.ControlToValidate = lstbox_Parts.ID;

    hth

    /Matthias

    Randel Bjorkquist wrote:
    > Hi all,
    >
    > I'm extremly new to building web-applications, C#, and the whole Microsoft
    > Visual Studio 2003 .NET IDE, so please bare with me.
    >
    > What I have:
    > I have a web-application that communicates to an SQL Server. My aspx file
    > is on a Windows 2000 Server running IIS. The base of the program is working
    > just ducky.
    >
    > My problem:
    > I'm trying to set the "ControlToValidate" property of a
    > "RequiredFieldValidator" at run time and get an exception when my code
    > executes. The error is "Unable to find control id
    > 'System.Web.UI.WebControls.ListBox' referenced by the 'ControlToValidate'
    > property of 'rfv_Parts'."
    >
    > CODE:
    > :
    > private void cmd_Submit_Click(object sender, System.EventArgs e){
    > rfv_Parts.ControlToValidate = lstbox_Parts.ToString();
    > :
    > }//END OF "cmd_Submit_Click" METHOD
    > :
    >
    > Can someone tell me why this isn't working?
    >
    > Thanks,
    >
    > Randel Bjorkquist
    >
    >
    Matthias S., Mar 29, 2005
    #2
    1. Advertising

  3. Hi Matthias,

    I think I'm going about my thought wrong. Long story short, I'm trying to
    validate if there are more then one item in a ListBox. I tried using a
    RequiredFieldValidator, but that doesn't work. So I thought I could assign
    it the control I wanted to in the OnClick event of a Button and work it that
    way and that was why I'm was trying to programmably set the
    "ControlToValidate" property.

    Like I said, I'm really after being able to figure out how to determine if
    there are at least one entery into a ListBox when I submit my Web Form.

    Does that make sense? I'm still stuck. I've tried a CustomeValidator and a
    RangeValidator, but I've had no luck with either. If you have any more
    sugguestions, please don't hessitate to do so, okay?

    Thank you,

    Randel Bjorkquist

    "Matthias S." <postamt@_remove_emvoid_remove_.de> wrote in message
    news:...
    > I'd try:
    >
    > rfv_Parts.ControlToValidate = lstbox_Parts.ID;
    >
    > hth
    >
    > /Matthias
    >
    > Randel Bjorkquist wrote:
    >> Hi all,
    >>
    >> I'm extremly new to building web-applications, C#, and the whole
    >> Microsoft Visual Studio 2003 .NET IDE, so please bare with me.
    >>
    >> What I have:
    >> I have a web-application that communicates to an SQL Server. My aspx
    >> file is on a Windows 2000 Server running IIS. The base of the program is
    >> working just ducky.
    >>
    >> My problem:
    >> I'm trying to set the "ControlToValidate" property of a
    >> "RequiredFieldValidator" at run time and get an exception when my code
    >> executes. The error is "Unable to find control id
    >> 'System.Web.UI.WebControls.ListBox' referenced by the 'ControlToValidate'
    >> property of 'rfv_Parts'."
    >>
    >> CODE:
    >> :
    >> private void cmd_Submit_Click(object sender, System.EventArgs e){
    >> rfv_Parts.ControlToValidate = lstbox_Parts.ToString();
    >> :
    >> }//END OF "cmd_Submit_Click" METHOD
    >> :
    >>
    >> Can someone tell me why this isn't working?
    >>
    >> Thanks,
    >>
    >> Randel Bjorkquist
    Randel Bjorkquist, Mar 29, 2005
    #3
    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. pc
    Replies:
    2
    Views:
    386
    Peter Chang
    Jul 28, 2003
  2. Vic
    Replies:
    2
    Views:
    342
  3. Curt_C [MVP]

    Re: RequiredFieldValidator question

    Curt_C [MVP], Apr 14, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    375
    Curt_C [MVP]
    Apr 14, 2004
  4. Steven Cheng[MSFT]

    RE: RequiredFieldValidator question

    Steven Cheng[MSFT], Apr 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,811
    Peter Blum
    Apr 15, 2004
  5. James Radke

    RequiredFieldValidator question..

    James Radke, Oct 14, 2003, in forum: ASP .Net Web Controls
    Replies:
    6
    Views:
    175
    Yan-Hong Huang[MSFT]
    Oct 29, 2003
Loading...

Share This Page