Solved

Hyperlink in dropdown list so when a selection is made redirects to that page

Posted on 2008-10-24
3
1,150 Views
Last Modified: 2012-05-05
I have a web site done in ASP.NET with VB.NET.  I have to add a dropdownlist that has hyperlinks so when somone selects an item from the list they are redirected to that URL.  I have the following, but it's taking me anywhere.  What am I doing wrong?

<asp:DropDownList id="ddlDropDown1" SelectedIndexChanged="RedirectMe" runat="server">
                  <asp:ListItem Value="product_list.aspx?id=8">Allergy Relief</asp:ListItem>
                  <asp:ListItem Value="product_list.aspx?id=11">Arthritis</asp:ListItem>
                  </asp:DropDownList>

Sub RedirectMe(ByVal s As Object, ByVal e As EventArgs)
        Dim RedirectUrl As String = ddlDropDown1.SelectedValue
        Response.Redirect(RedirectUrl)
    End Sub
0
Comment
Question by:OVC-it-guy
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
ahll earned 500 total points
ID: 22800295
Hi
Try this code

Just make sure of having set the AutoPostback for the DDL.

Hope it helps
aspx page
 
    <asp:DropDownList
        ID="DropDownList1" runat="server" AutoPostBack="True" 
            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem Value="mypage.aspx?id=1">First Choice</asp:ListItem>
        <asp:ListItem Value="mypage.aspx?id=2">Second Choice</asp:ListItem>
    </asp:DropDownList>
 
 
aspx.cs page
 
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Response.Redirect(DropDownList1.SelectedValue.ToString());
        }

Open in new window

0
 

Author Comment

by:OVC-it-guy
ID: 22800510
Can I get that in VB.NET, since the rest of the page is?
0
 

Author Closing Comment

by:OVC-it-guy
ID: 31509833
Thank you anyway.  I got the VB.NET myself.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

775 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question