Link to home
Start Free TrialLog in
Avatar of hacresIT
hacresITFlag for United States of America

asked on

vb.net if...then statement help

Ok, I know this is a simple question...so I hope I can get a quick answer.

I'm trying to do a if, then statement that checks for one criteria, and has multiple responses based upon the criteria. The problem is, only ONE response is given, while I want THREE actions to take place. The following is the code;

        If ddlLocation.Text = "Lake Lure, NC" Then
            imgLocation.ImageUrl = "~/halc/images/lakeOff.jpg"
            lblContact.Visible = True
            lblLocPhone.Text = "(877)743-2589"
        ElseIf ddlLocation.Text = "Stanton, KY" Then
            imgLocation.ImageUrl = "~/halc/images/StantonOff.jpg"
            lblContact.Visible = True
            lblLocPhone.Text = "(877)220-0005"
        ElseIf ddlLocation.Text = "Plant City, FL" Then
            imgLocation.ImageUrl = "~/halc/images/PlantOff.jpg"
            lblContact.Visible = True
            lblLocPhone.Text = "(866)757-1771"
        ElseIf ddlLocation.Text = "Fallbrook, CA" Then
            imgLocation.ImageUrl = "~/halc/images/fallbrookOff.jpg"
            lblContact.Visible = True
            lblLocPhone.Text = "(760)728-1064"
        Else
            imgLocation.ImageUrl = "~/halc/images/NoLoc.jpg"
            lblContact.Visible = False
            lblLocPhone.Text = ""
        End If

I am hoping someone can tell me what I'm missing. I know it's simple (and I'll feel stupid once someone answers the question) I just don't know it.
Avatar of mastoo
mastoo
Flag of United States of America image

Can you elaborate on what you mean by "only ONE response is given, while I want THREE actions to take place"?  If you're referring to having 3 statements inside each branch of the "if" statement, what you have will execute all 3.
Use ddlLocation.SelectedItem.Text  instead of ddlLocation.Text.
Avatar of hacresIT

ASKER

Ok, as it is, when an item is selected, the only thing that currently happens is the image changes as directed by the code;  imgLocation.ImageUrl = "~/halc/images/PlantOff.jpg"

The asp.net lables DO NOT change as directed by the statements given;

 lblContact.Visible = True
 lblLocPhone.Text = "(866)757-1771"


ASKER CERTIFIED SOLUTION
Avatar of Edward
Edward
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial