By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,061 Members | 1,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,061 IT Pros & Developers. It's quick & easy.

hyperlinks as part of dropdownlist

P: n/a
Just wondering if there is a way to set up hyperlinks in a drop down list, so each item in the dropdown list navigates to a different page.
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
CW
I don't know whether you want an immediate redirect to a page once user
selects an item from the drop down box or simply presents a URL for user to
go to.

Either way, you simply make sure to set the drop down box to autopostback.
If it's the former you require, simply call redirect method in the event
handler of the selectedindex_changed method of the drop down box. If the
latter, you need to have a second control (easiest being a hyperlink object
on the same web form) and set its navigateurl in the event handler of the
drop down box.

HTT
"Paul" <an*******@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
Just wondering if there is a way to set up hyperlinks in a drop down list,

so each item in the dropdown list navigates to a different page.
Nov 18 '05 #2

P: n/a
You can't exactly put hyperlinks in the list, but you could redirect
to a URL depending on what item the user has select in the control.

For example, if the following was in a web form:

<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem Value="http://msdn.microsoft.com"
Selected="True">MSDN
</asp:ListItem>
<asp:ListItem Value="http://www.asp.net">ASP.Net
</asp:ListItem>
<asp:ListItem Value="http://www.google.com">Google
</asp:ListItem>
</asp:DropDownList>
<asp:Button id="Button1" runat="server" Text="Go"/>
Then you could add an event handler for the button click event and do
the following:

private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect(DropDownList1.SelectedValue);
}

HTH,

--
Scott
http://www.OdeToCode.com

On Wed, 5 May 2004 07:51:03 -0700, "Paul"
<an*******@discussions.microsoft.com> wrote:
Just wondering if there is a way to set up hyperlinks in a drop down list, so each item in the dropdown list navigates to a different page.


Nov 18 '05 #3

P: n/a
Hi thanks for the response. I need to open a new window based on the selection, so may use window.open with some conditional code in the dropdown list change event.
Nov 18 '05 #4

P: n/a
ok thanks for the information.
Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.