using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace NoCodeBehind
{
public partial class CapitalsGame_CB : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnCapital_Click(object sender, EventArgs e)
{
string guess =
txtCapital.Text;
guess = guess.Trim();
string answer
= GetCapital(lstStates.SelectedValue);
if (guess == answer)
{
lblCapital.Text
= "You're correct, the capital is " + answer + "!";
}
else
{
lblCapital.Text
= "That wasn't the correct state's
capital. Please try again.";
}
}
public string GetCapital(string state)
{
string capital
= "";
switch (state)
{
case "Pennsylvania":
capital
= "Harrisburg";
break;
case "New Jersey":
capital
= "Trenton";
break;
case "New York":
capital
= "Albany";
break;
}
return
capital;
}
}
}