RequiredFieldValidator Question

R

Randel Bjorkquist

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
 
R

Randel Bjorkquist

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top