?
Solved

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

Posted on 2008-10-24
3
Medium Priority
?
1,154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
ahll earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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