hacresIT
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.jp g"
lblContact.Visible = True
lblLocPhone.Text = "(866)757-1771"
ElseIf ddlLocation.Text = "Fallbrook, CA" Then
imgLocation.ImageUrl = "~/halc/images/fallbrookOf f.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.
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.
lblContact.Visible = True
lblLocPhone.Text = "(877)220-0005"
ElseIf ddlLocation.Text = "Plant City, FL" Then
imgLocation.ImageUrl = "~/halc/images/PlantOff.jp
lblContact.Visible = True
lblLocPhone.Text = "(866)757-1771"
ElseIf ddlLocation.Text = "Fallbrook, CA" Then
imgLocation.ImageUrl = "~/halc/images/fallbrookOf
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.
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.T ext instead of ddlLocation.Text.
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.jp g"
The asp.net lables DO NOT change as directed by the statements given;
lblContact.Visible = True
lblLocPhone.Text = "(866)757-1771"
The asp.net lables DO NOT change as directed by the statements given;
lblContact.Visible = True
lblLocPhone.Text = "(866)757-1771"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.