We help IT Professionals succeed at work.
Get Started

setting up a parameter for redirect

-Dman100-
-Dman100- asked
on
340 Views
Last Modified: 2010-04-16
I have the following code in my page Load:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string redirector = HttpContext.Current.Request.Url.AbsoluteUri.Remove(0, 7);
            if (redirector.StartsWith("az"))
            {
                Response.Redirect("http://state-solutions.compasslearning.com/statedetails.aspx?id=AZ");
            }
            else if (redirectory.StartsWith("..."))
            {
                etc...
            }
            else if (redirector.StartsWith("tn"))
            {
                Response.Redirect("http://state-solutions.compasslearning.com/statedetails.aspx?id=TN");
            }
            else
            {
                state.DataSource = StateDAO.GetStateList();
                state.DataValueField = "PK";
                state.DataTextField = "name";
                state.DataBind();
                state.Items.Insert(0, new ListItem("----- Please Select -----", ""));
            }
        }
    }

how can I set a parameter for the StartWith("state_abbreviation"), so I don't have to type in every single state_abbreviation for the redirects, which would be about 60 for all the US states and territories?

Thanks for any help.
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE