Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vb.net if...then statement help

Posted on 2007-11-26
4
Medium Priority
?
536 Views
Last Modified: 2009-12-16
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.
0
Comment
Question by:hacresIT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 21

Expert Comment

by:mastoo
ID: 20350790
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.
0
 
LVL 4

Expert Comment

by:edwardq
ID: 20350813
Use ddlLocation.SelectedItem.Text  instead of ddlLocation.Text.
0
 
LVL 1

Author Comment

by:hacresIT
ID: 20350940
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"


0
 
LVL 4

Accepted Solution

by:
edwardq earned 150 total points
ID: 20351017
Are you setting up the lblContact.Visable = false in the Page_Load? if so you need to check to see if its a this is a page postback.  If so, skip the lblContact and the LocPhone.Text = "".
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question