我的前台是这样写的:
<asp:DropDownList ID="DropDownList1" runat="server" Width="200" AutoPostBack="true"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="111.aspx">111</asp:ListItem>
<asp:ListItem Value="222.aspx">222</asp:ListItem>
<asp:ListItem Value="333.aspx">333</asp:ListItem>
</asp:DropDownList>
后台是:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Redirect(DropDownList1.SelectedValue);
}
但是代码实现不了我想要的工能。请哪个高手指点一下
<asp:DropDownList ID="DropDownList1" runat="server" Width="200" AutoPostBack="true"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="111.aspx">111</asp:ListItem>
<asp:ListItem Value="222.aspx">222</asp:ListItem>
<asp:ListItem Value="333.aspx">333</asp:ListItem>
</asp:DropDownList>
后台是:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Redirect(DropDownList1.SelectedValue);
}
但是代码实现不了我想要的工能。请哪个高手指点一下
DropDownList1.SelectedItem.Text
日 人家有你在value中写 value=1在cs中if(value==1){跳转页面}
<asp:DropDownList ID="DropDownList1" runat="server" Width="200" AutoPostBack="true"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value=""> - 请选择 - </asp:ListItem>
<asp:ListItem Value="111.aspx">111</asp:ListItem>
<asp:ListItem Value="222.aspx">222</asp:ListItem>
<asp:ListItem Value="333.aspx">333</asp:ListItem>
</asp:DropDownList>protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex > 0)
Response.Redirect(DropDownList1.SelectedItem.Text);
}
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="aa.aspx">aa</asp:ListItem>
<asp:ListItem Value="Default.aspx">default</asp:ListItem>
<asp:ListItem Value="bb.aspx">bb</asp:ListItem>
</asp:DropDownList>
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Redirect(DropDownList1.SelectedValue);
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex > 0)
Response.Redirect(DropDownList1.SelectedValue);
}
好像没啥问题吧
不管跳转到那都都是的。
<asp:ListItem Value="111.aspx">111</asp:ListItem>
改成
<asp:ListItem Value="111.aspx" Text="111"></asp:ListItem>
改成Response.Redirect(""+DropDownList1.SelectedValue+"");
但是,每个页面要设dropdownlist的默认值
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
///其他页面以此类推
this.DropDownList1.SelectedIndex = 0;
}
}
那在Page_Load事件函数里要设置在当前页的DROPDOWNLIST应该显示哪一个选项
比如在222.aspx
那么就加上
this.DropDownList1.SelectedIndex =1;