自动跳转?
==========
<asp:dropdownlist id=myDLL autopostback=true selectedindexchanged="myDDL_selectedindexchanged" ...protected void myDDL_selectedindexchanged(..
{
Response.Redirect(myDLL.SelectedValue);
}
还有要不要新建数据表?
==========
不明白...
==========
<asp:dropdownlist id=myDLL autopostback=true selectedindexchanged="myDDL_selectedindexchanged" ...protected void myDDL_selectedindexchanged(..
{
Response.Redirect(myDLL.SelectedValue);
}
还有要不要新建数据表?
==========
不明白...
<asp:dropdownlist id=myDLL autopostback=true selectedindexchanged="myDDL_selectedindexchanged" ... protected void myDDL_selectedindexchanged(..
{
Response.Redirect(myDLL.SelectedValue);
}
这种方法是正确的
2.
(1)你可以选择直接在dropdownlist里编辑所有的网址
(2)或者你建一个表存储所有的网址
然后取出绑定
(1)好处,节省页面加载速度,提高性能,缺点:就是所谓的“死的”,不能及时的更新
(2)好处,能够及时更新,可以做一个页面添加删除所以的网址
缺点:性能差你看看你适合哪个
而且不要用Response.Redirect(myDLL.SelectedValue); 这种办法。<asp:DropDownList ID="ddlState" runat="server" AppendDataBoundItems="True"
DataTextField="LinkName" DataValueField="LinkUrl">
<asp:ListItem Selected="True">-- 政府及省直各厅局网站 --</asp:ListItem>
</asp:DropDownList>ddlState.DataSource = friendLinkManager.GetLinkList("政府及省直各厅局网站");
ddlState.DataBind();
ddlState.Attributes["onChange"] = "javascript:window.open(this.options[this.selectedIndex].value)";利用OnChange客户端事件就可以实现跳转了。
[DefaultProperty("Text")]
[ToolboxData("<{0}:JumpSelector runat=server></{0}:JumpSelector>")]
public class JumpSelector : DropDownList
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
Page.ClientScript.RegisterClientScriptBlock(GetType(), "go_jump",
@"<script language=""javascript"">
function go_jump(oJumpSelector){
window.open( oJumpSelector.value );
}
</script>");
} protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender(writer);
writer.AddAttribute("onchange", "javascript:go_jump(this);return false;");
}
}使用的代码:
<dft:JumpSelector ID="JumpSelector1" runat="server">
<asp:ListItem Value="http://www.163.com">网易</asp:ListItem>
<asp:ListItem Value="http://www.sina.com">新浪</asp:ListItem>
<asp:ListItem Value="http://www.sohu.com">搜狐</asp:ListItem>
</dft:JumpSelector>
.net:autopostback.
都可以的.表最好新建个,长久打算的话.