Drop Down List and AutoPostBack. Really urgent. Thank You Very Much

Discussion in 'ASP .Net' started by Miguel Dias Moura, Apr 5, 2004.

  1. Hello,

    I have a Drop Down List with 3 options. I want to redirect to a new page
    when an options is selected. I don't want to use a button. The redirection
    should be fired when the option is selected.

    I have an ASP.net / VB page with a Drop Down List named "my select" as
    follows:

    <asp:DropDownList AutoPostBack="true" ID="myselect" runat="server">
    <asp:ListItem value="www.google.com">Google</asp:ListItem>
    <asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
    <asp:ListItem value="www.macromedia.com">Macromedia</asp:ListItem>
    </asp:DropDownList>

    Then i have this script:

    <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>

    I looked in the .net and tryied several options but until now i wasn't able
    to make it work

    This seems really simple. I don't know what is going on and i need to
    deliver this as soon as possible. Can you help me?

    Thank You,
    Miguel
     
    Miguel Dias Moura, Apr 5, 2004
    #1
    1. Advertising

  2. Miguel Dias Moura

    Rajiv R Guest

    Hi Miguel,

    Use the OnSelectedIndexChanged event of dropdownlist.

    > <asp:DropDownList AutoPostBack="true" ID="myselect" runat="server"

    OnSelectedIndexChanged="myselect_Change">
    > <asp:ListItem value="www.google.com">Google</asp:ListItem>
    > <asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
    > <asp:ListItem

    value="www.macromedia.com">Macromedia</asp:ListItem>
    > </asp:DropDownList>


    then you can write the handler as
    void myselect_Change(Object sender, EventArgs e) {

    }

    --
    Cheers!
    Rajiv. R
    Rajspace.Org

    "Miguel Dias Moura" <> wrote in message
    news:#...
    > Hello,
    >
    > I have a Drop Down List with 3 options. I want to redirect to a new page
    > when an options is selected. I don't want to use a button. The redirection
    > should be fired when the option is selected.
    >
    > I have an ASP.net / VB page with a Drop Down List named "my select" as
    > follows:
    >
    > <asp:DropDownList AutoPostBack="true" ID="myselect" runat="server">
    > <asp:ListItem value="www.google.com">Google</asp:ListItem>
    > <asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
    > <asp:ListItem

    value="www.macromedia.com">Macromedia</asp:ListItem>
    > </asp:DropDownList>
    >
    > Then i have this script:
    >
    > <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>
    >
    > I looked in the .net and tryied several options but until now i wasn't

    able
    > to make it work
    >
    > This seems really simple. I don't know what is going on and i need to
    > deliver this as soon as possible. Can you help me?
    >
    > Thank You,
    > Miguel
    >
    >
    >
    >
    >
     
    Rajiv R, Apr 5, 2004
    #2
    1. Advertising

  3. There was already a response in :

    03/04/2004 -- Re: Jump Menu (DropDown Menu) in ASP.net. Can someone help
    me out?


    <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).SelectedValue);
    }

    </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_SelectedIndexChanged">
    <asp:ListItem value="">select one...</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>



    "Rajiv R" <> wrote in message
    news:e$...
    > Hi Miguel,
    >
    > Use the OnSelectedIndexChanged event of dropdownlist.
    >
    > > <asp:DropDownList AutoPostBack="true" ID="myselect" runat="server"

    > OnSelectedIndexChanged="myselect_Change">
    > > <asp:ListItem value="www.google.com">Google</asp:ListItem>
    > > <asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
    > > <asp:ListItem

    > value="www.macromedia.com">Macromedia</asp:ListItem>
    > > </asp:DropDownList>

    >
    > then you can write the handler as
    > void myselect_Change(Object sender, EventArgs e) {
    >
    > }
    >
    > --
    > Cheers!
    > Rajiv. R
    > Rajspace.Org
    >
    > "Miguel Dias Moura" <> wrote in message
    > news:#...
    > > Hello,
    > >
    > > I have a Drop Down List with 3 options. I want to redirect to a new page
    > > when an options is selected. I don't want to use a button. The

    redirection
    > > should be fired when the option is selected.
    > >
    > > I have an ASP.net / VB page with a Drop Down List named "my select" as
    > > follows:
    > >
    > > <asp:DropDownList AutoPostBack="true" ID="myselect" runat="server">
    > > <asp:ListItem value="www.google.com">Google</asp:ListItem>
    > > <asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
    > > <asp:ListItem

    > value="www.macromedia.com">Macromedia</asp:ListItem>
    > > </asp:DropDownList>
    > >
    > > Then i have this script:
    > >
    > > <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>
    > >
    > > I looked in the .net and tryied several options but until now i wasn't

    > able
    > > to make it work
    > >
    > > This seems really simple. I don't know what is going on and i need to
    > > deliver this as soon as possible. Can you help me?
    > >
    > > Thank You,
    > > Miguel
    > >
    > >
    > >
    > >
    > >

    >
    >
     
    Bruno Sirianni, Apr 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miguel Dias Moura
    Replies:
    2
    Views:
    344
    Martin
    Jun 22, 2004
  2. Shapper
    Replies:
    1
    Views:
    391
    Shapper
    Oct 29, 2005
  3. Miguel Dias Moura
    Replies:
    0
    Views:
    364
    Miguel Dias Moura
    Jan 28, 2006
  4. Miguel Dias Moura

    Data List Question. Urgent. Thank You Very Much.

    Miguel Dias Moura, Sep 27, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    119
    Miguel Dias Moura
    Sep 27, 2004
  5. Miguel Dias Moura

    Data List Question. Urgent. Thank You Very Much.

    Miguel Dias Moura, Sep 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    115
    Miguel Dias Moura
    Sep 27, 2004
Loading...

Share This Page