Try with this :
<script runat=server language=C#>
private void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
private void DropDownList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
if (((DropDownList)sender).SelectedValue != "")
Response.Redirect(((DropDownList)sender).SelectedV alue);
}
</script>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server" OnLoad="Page_Load">
<asp:DropDownList id="DropDownList1" style="Z-INDEX: 101; LEFT: 184px;
POSITION: absolute; TOP: 184px"
runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged">
<asp:ListItem value="">item0</asp:ListItem>
<asp:ListItem
value="http://www.bonsalunos.com">item1</asp:ListItem>
<asp:ListItem value="http://www.sapo.pt">item2</asp:ListItem>
<asp:ListItem value="http://www.google.com">item3</asp:ListItem>
</asp:DropDownList>
</form>
</body>
"Miguel Dias Moura" <in************@27lamps.com> wrote in message
news:ej**************@TK2MSFTNGP11.phx.gbl...
Hi,
i wrote this script but it's not working as i expected. Can you tell me
what am i doing wrong?
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
if myselect.AutoPostBack then
Response.Redirect ("http://" &
myselect.items(myselect.SelectedIndex).Value)
end if
End Sub
</script>
Drop Down Menu:
<asp:DropDownList AutoPostBack="true" ID="myselect" runat="server">
<asp:ListItem value="www.bonsalunos.com">item1</asp:ListItem>
<asp:ListItem value="www.sapo.pt">item2</asp:ListItem>
<asp:ListItem value="www.google.com">item3</asp:ListItem>
</asp:DropDownList>
Thanks,
Miguel
"Bruno Sirianni" <br***********@virgilio.it> wrote in message
news:Z_*******************@news3.tin.it... <asp:DropDownList /> have AutoPostBack property. If this property is set to true it automatically when change the List value fire a
SelectedIndexChanged event on Page.
In this method you can switch the DropDownList.SelectedValue and make a
Redirect where you want.
Brun
"Miguel Dias Moura" <in************@27lamps.com> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl... Hello,
i have a drop down menu in ASP.net with 5 options. I want to redirect
to a certain page when a certain option is selected.
I want to be redirected without having to click a button. Does anyone
knows how to make this?
Thank You,
Miguel