简体   繁体   中英

How do I to redirect to another aspx?

So I am working on a game for a college project and I am having trouble redirecting to a different aspx. The DDL has three levels of difficulty Easy, Medium, and Hard. I managed somehow to get the easy level to redirect to the correct aspx page but when I select Medium or Hard and click on the Go button it continues to redirect to the easy aspx. How can I fix this? Thank you in advance. This is what I have in the Button. I am not sure if this is correct. I am still learning

        DDL1.DataValueField = Convert.ToString("Easy");
        DDL1.DataValueField = Convert.ToString("Medium");
        DDL1.DataValueField = Convert.ToString("Hard");


        if (difficultyValue == Easy)
        {

            Response.Redirect("/My code/GuessTheNumber.aspx", true);
        }
        else if (difficultyValue == Medium)
        {
            Response.Redirect("~/Medium.aspx", true);
        }
        else if (difficultyValue == Hard)
        {
            Response.Redirect("~/Hard.aspx", true);
        }`

Assuming your assignment is wrong then you can try this code and this might work for you:

if (DDL1.DataValueField == "Easy")
{
    Response.Redirect("/My code/GuessTheNumber.aspx", true);
}
else if (DDL1.DataValueField == "Medium")
{
    Response.Redirect("~/Medium.aspx", true);
}
else if (DDL1.DataValueField == "Hard")
{
    Response.Redirect("~/Hard.aspx", true);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM