日期:2014-05-17  浏览次数:20374 次

DropDownList做友情链接
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>

下拉控件用来做后台友情链接的,选择的时候会自动链接到其他网址,

我只能获取value值,不能跳转网址。。。

求代码。。。。。。

------解决方案--------------------
探讨

启用AutoPostBack
C# code

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string href = this.DropDownList1.SelectedValue;//http://www.baidu.com
……

------解决方案--------------------
DropDownList1的AutoPostBack=“true”
绑定:
selectValue="网址"
selectText="名称"

SelectedIndexChanged事件
url=DropDownList1.SelectedItem.Value
跳转 Response.Redirect(href);



------解决方案--------------------
<asp:DropDownList ID="DropDownList1" runat="server" onchange="window.location=this.value">
<asp:ListItem Value="http://xxxxx">xx</asp:ListItem>
</asp:DropDownList>