Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.

Friday, September 14, 2007

C# switch statement for DropDownList to update Image url.

Simple control-flow statement to reference C# switch statement, which is similar to other language's case statement.


switch (DropDownList1.SelectedValue)
{
case "Image 1":
imgFoo.ImageUrl = "images/photo1.jpg";
break;
case "Image 2":
imgFoo.ImageUrl = "images/photo2.jpg";
break;
case "Image 3":
imgFoo.ImageUrl = "images/photo3.jpg";
break;
default:
imgFoo.ImageUrl = "images/photo_blank.jpg";
break;
}

1 comment:

Anonymous said...

Nice post and this fill someone in on helped me alot in my college assignement. Thank you as your information.