6.1---F5运行,可是我们发现这下拉框选择时什么事也没发生的解决
ASPX中的代码为:
<asp:DropDownList id="dlstWeb" style="Z-INDEX: 101; LEFT: 32px;
POSITION: absolute; TOP: 32px" runat="server"
Width="88px" AutoPostBack="True">
<asp:ListItem value="http://www.sina.com.cn">新浪 </asp:ListItem>
<asp:ListItem value="http://www.sohu.com">搜狐</asp:ListItem>
<asp:ListItem value="http://www.163.com">网易</asp:ListItem>
</asp:DropDownList>
在下拉框的SelectedIndexChanged事件中的加入代码:
private void dlstWeb_SelectedIndexChanged(object sender, System.EventArgs e)
{
Response.Write("<script language=javascript>window.open('" +dlstWeb.Selectedvalue + "');</script>");
}
按F5运行,可是我们发现这下拉框选择时什么事也没发生。原来原因是出在下拉框的AutoPostBack属性上,把它设为true后再试试,一切OK了。
<asp:DropDownList id="dlstWeb" style="Z-INDEX: 101; LEFT: 32px;
POSITION: absolute; TOP: 32px" runat="server"
Width="88px" AutoPostBack="True">
<asp:ListItem value="http://www.sina.com.cn">新浪 </asp:ListItem>
<asp:ListItem value="http://www.sohu.com">搜狐</asp:ListItem>
<asp:ListItem value="http://www.163.com">网易</asp:ListItem>
</asp:DropDownList>
在下拉框的SelectedIndexChanged事件中的加入代码:
private void dlstWeb_SelectedIndexChanged(object sender, System.EventArgs e)
{
Response.Write("<script language=javascript>window.open('" +dlstWeb.Selectedvalue + "');</script>");
}
按F5运行,可是我们发现这下拉框选择时什么事也没发生。原来原因是出在下拉框的AutoPostBack属性上,把它设为true后再试试,一切OK了。