Need syntax to add additional conditions to ASP C# statement

Hi, I need to add three additional conditions to the below ASP C# statement and am unsure of syntax to do this. The below statement works fine:

If landingQ1 = "home", go to home.aspx. If anything else, go to church.aspx

SuccessURL='<%# ( Request.Form["landingQ1"] == 
"home" ? "home.aspx" : "church.aspx" ) + "?rurlID=" 
+ Session["XMPRecipientID"] %>'

Open in new window


What I need to have, is:

If landingQ1 = "home", go to home.aspx
If landingQ1 = "church", go to church.aspx
If landingQ1 = "school", go to school.aspx
If landing Q1 = "PerformanceHall", go to performancehall.aspx
If anything else, goto sorrypage.html

I am not familiar with this syntax and am not sure what to Google to find information about this syntax. Any advise would be great. Thanks!
Mark BDirector ITAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi alphagraphics297;

Try it like this and see if it works out for you.

SuccessURL='<%# ( Request.Form["landingQ1"] == 
  "home" ? "home.aspx" : 
  "church" ? "church.aspx" :
  "school" ? "school.aspx" :
  "PerformanceHall" ? "performancehall.aspx" :
  "sorrypage.html") + "?rurlID=" 
  + Session["XMPRecipientID"] %>'

Open in new window

0
louisfrCommented:
The conditional operator doesn't work like that. You're confusing with the switch statement.
SuccessURL='<%# ( Request.Form["landingQ1"] == "home" ? "home.aspx" : 
  Request.Form["landingQ1"] == "church" ? "church.aspx" :
  Request.Form["landingQ1"] == "school" ? "school.aspx" :
  Request.Form["landingQ1"] == "PerformanceHall" ? "performancehall.aspx" :
  "sorrypage.html") + "?rurlID=" 
  + Session["XMPRecipientID"] %>'

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fernando SotoRetiredCommented:
Hi alphagraphics297;

Reposted my original solution to correct the error I made in not putting in the condition of the conditional operator (?:).

SuccessURL='<%# ( Request.Form["landingQ1"] == "home" ? "home.aspx" :
  Request.Form["landingQ1"] == "church" ? "church.aspx" :
  Request.Form["landingQ1"] == "school" ? "school.aspx" :
  Request.Form["landingQ1"] == "PerformanceHall" ? "performancehall.aspx" :
  "sorrypage.html") + "?rurlID="
  + Session["XMPRecipientID"] %>'

@louisfr, Thanks for catching that I was responding to the question from my iPad and was going to copy and paste that part of the line seeming it was the same for the other lines, I just hate those virtual keyboards.
0
Mark BDirector ITAuthor Commented:
Thank you this works
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.