Go Back   SitePoint Forums > Forum Index > Program Your Site > .NET
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Sep 21, 2004, 16:51   #1
Bluebarry
Non-Member
 
Bluebarry's Avatar
 
Join Date: Aug 2004
Location: Star Trek Voyager
Posts: 193
QUICK HELP: C#.Net Syntax Error

Hey, I need some help on this piece of code.

Overview:
I created a wizard program, the wizard pages are included in a sperate DLL file which my project has references too, all controls on the wizard pages have their modifiers set to public. I have no problem communicating with the wizard pages from my application, however I'm getting an error in this section when trying to read all the controls at once.

Code:
foreach (TextBox tbValidate in DbWizPage1.Controls)
{
if (tbValidate.Tag == "Required")
{
if (tbValidate.Text == string.Empty)
{
DbWizPage1.errorProvider1.SetError(tbValidate,"Required Field");
}
else
{
DbWizPage1.errorProvider1.SetError(tbValidate, "");
}
}
}
I'm trying to check all the text box controls on the page. Locate the controls that are required and check to insure data has been inserted in them. I'm not to the point of validating the data, just want to insure it's there. This should check every text box on page1, find out if it's required, if so, then check to insure data is available, if not tell the error provider to mark that control as invalid.

I keep getting an invalid cast error on the first line. If there is another solution I would be open to it. There are about 30 controls on page one, and many more on additional pages. I don't want to have to include code to check every single field, that would just be insane. I had a lovely idea of taging the controls as required, checking the entire collection and disreguarding the contorls not required, but it dosen't like my method I guess.

Site point once again dose not allow formatting of code samples since it completely destroyed it again... wish they'd fix that bug.

Thanks, Everyone
Bluebarry is offline   Reply With Quote
 

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 00:35.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved