读书人

DropDownList做友情链接解决方案

发布时间: 2012-05-04 12:36:09 作者: rapoo

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>

读书人网 >asp.net

热点推荐