如何让我的下拉列表导航到项目选择上的另一个页面

时间:2014-01-08 00:47:37

标签: c# asp.net

我有一个下拉列表控件,我希望它在用户选择其中一个选项后将用户发送到我网站中的另一个页面。我是Asp.Net/C#的新手,很难弄清楚我的OnInit()在后面的代码中的位置,所以我可以重定向到其他页面。谁能帮我这个?这是我的代码隐藏:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {


    }
}

我想这样做"没有"如果可能的话,使用javascript或JQuery。如果有人能为我说明这一点,我会非常感激。感谢。

3 个答案:

答案 0 :(得分:0)

欢迎来到ASP.Net的话。寻找Response.Redirect方法。

Response.Redirect(URL);

答案 1 :(得分:0)

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
       //Redirect to other page  
       Response.Redirect("YOUR_NEW_PAGE.aspx");

}

答案 2 :(得分:0)

在设置

后放置此代码
  

自动回发

Dropdownlist的

属性为true

protected void Page_Load(object sender, EventArgs e)
    {
        DropDownList1.Items.Add("Home");
        DropDownList1.Items.Add("Login");
        DropDownList1.Items.Add("Signup");
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string sUrl = DropDownList1.SelectedItem.Text + ".aspx";
        Response.Redirect(sUrl);
    }