Peter,
Can you be more specific with a couple lines of code as an example? I am a newbie so please be patient with me. As far as the gazillion if statements, how else can I achieve what I am after? What I am after is this, I have a form and am doing validation. What I want is to check each text box for validation and if it is empty for example then turn the Lbl to red. I know there are built in validation functions but I dont' think they can achieve turning a label to red. --- In [EMAIL PROTECTED], "Peter Brunone" <[EMAIL PROTECTED]> wrote: > Hi Mike, > > Without commenting on the gazillion If statements, why do you > have a Return in each one? You could just set a boolean variable when > one of the conditions is met, and then when the If statements are > finished, if the variable is flipped, you don't do the insert. > > Cheers, > > Peter > > -----Original Message----- > From: Mike Appenzellar [mailto:[EMAIL PROTECTED] > > As you will see below, I have some pretty simple code. My question is > this...On each If stament, I have a Return, which works, but what I want > to happen is when onSubmit show everything that is required in red...the > Return in each if now forces it to only show one at a time until that > condition is met. So...if fname and lname is blank, fname will turn to > red, once I fill in fname and hit submit, then lname is red and fname is > black which is correct, but on the initial click both fname and lname > should be red. > > Private Sub submitBtn_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles submitBtn.Click > If fnameTxt.Text.Trim() = "" Then > fnameLbl.ForeColor = Color.Red > Return > End If > If lnameTxt.Text.Trim() = "" Then > lnameLbl.ForeColor = Color.Red > Return > End If > If streetAddressTxt.Text.Trim() = "" Then > streetAddressLbl.ForeColor = Color.Red > Return > End If > If cityTxt.Text.Trim() = "" Or stateTxt.Text.Trim() = "" Or > zipTxt.Text.Trim() = "" Then > cityStateZipLbl.ForeColor = Color.Red > Return > End If > If telephoneTxt.Text.Trim() = "" Then > telephoneLbl.ForeColor = Color.Red > Return > End If > If sexTxt.SelectedValue = "" Then > sexLbl.ForeColor = Color.Red > Return > End If > If dobTxt.Text.Trim() = "" Then > dobLbl.ForeColor = Color.Red > Return > End If > If userIdTxt.Text = "" Then > userIdLbl.ForeColor = Color.Red > Return > End If > If passwordTxt.Text.Trim() = "" Then > passwordLbl.ForeColor = Color.Red > Return > End If > If confirmPasswordTxt.Text.Trim() = "" Then > confirmPasswordLbl.ForeColor = Color.Red > Return > End If > If Not IsDate(dobTxt.Text) Then > dobLbl.ForeColor = Color.Red > Return > End If > > 'SQL Insert data' > Dim Conn As SqlConnection > Dim Rdr As SqlDataReader > Dim strConn As String = AppSettings("ConnectInfoHere") > Dim strSQL As String = "INSERT INTO ONLINE_SUBSCRIBERS (fname, > lname, streetAddress, city, state, zip, userID, password, phoneNumber, > dob) VALUES ('" + fnameTxt.Text.Trim() + "', '" + lnameTxt.Text.Trim () > + "', '" + streetAddressTxt.Text.Trim() + "','" + cityTxt.Text.Trim () > + "','" + stateTxt.Text.Trim() + "','" + zipTxt.Text.Trim() + "','" + > userIdTxt.Text.Trim() + "','" + passwordTxt.Text.Trim() + "','" + > telephoneTxt.Text.Trim() + "','" + dobTxt.Text.Trim() + "')" > Conn = New SqlConnection(strConn) > Dim Cmd As New SqlCommand(strSQL, Conn) > Conn.Open() > Cmd.ExecuteNonQuery() > Response.Redirect("/nextpage.aspx") > End Sub ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
