Thanks. That makes total sense...I am a cold fusion guy so the thought
process is a bit different. You do still think that I have too many IF
statements though? Any way to streamline those?

Thanks. 


On Mon, 6 Dec 2004 17:34:30 -0600, Peter Brunone <[EMAIL PROTECTED]> wrote:
> 
>       Well, I was thinking something like this:
> 
> Private Sub submitBtn_Click(ByVal sender As System.Object, ByVal e
>   As System.EventArgs) Handles submitBtn.Click
>          Dim binFailed As Boolean = False
> 
>          If fnameTxt.Text.Trim() = "" Then
>              fnameLbl.ForeColor = Color.Red
>              binFailed = True
>          End If
>          If lnameTxt.Text.Trim() = "" Then
>              lnameLbl.ForeColor = Color.Red
>              binFailed = True
>          End If
> 
> ...and so on until the end, where you'd do this right before the
> database operation:
> 
> If binFailed = True Then
>    Return
> End If
> 
> 
> 
> 
> -----Original Message-----
> From: mappenzellar [mailto:[EMAIL PROTECTED] 
> 
> 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
> 
> ADVERTISEMENT
> 
> 
> ________________________________
> 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 the Yahoo! Terms of Service.


------------------------ Yahoo! Groups Sponsor --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/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/
 



Reply via email to