OnClick Event in A Select Dropdown Menu (ASP)

Is it possible to have an onClick event fired off when something is selected from a Select dropdown list in ASP?  Similar to how a button when clicked performs an action I would like when an item is selected from a dropdown list that it immediately opens a new page.  This way it does not require the user to select the item from the drop down, then hit a submit button.

this is what I used for one of my buttons.
<input type="button" value="Refresh" onClick="location.href='<%= Me.NewURL.ToString() %>';">

Is there a way to use this method for a dropdown?  Something like
<input type="dropdown" value="Refresh" onClick="location.href='<%= Me.NewURL.ToString() %>';">
Who is Participating?
shankwheatConnect With a Mentor Commented:

I think this is what you need if you're using classic ASP.  You can change _top to _blank if you want a new browser window.

<form action="../">
<select onchange="window.open(this.options[this.selectedIndex].value,'_top')">
    <option value="">Choose a destination...</option>
    <option value="http://www.yahoo.com/">YAHOO</option>
    <option value="http://www.google.com/">GOOGLE</option>
    <option value="http://www.altavista.com/">ALTAVISTA</option>
    <option value="http://www.amazon.com/">AMAZON</option>
    <option value="http://artlung.com/">ARTLUNG</option>


You can simply do something like:

<asp:DropDownList ID="ddl" runat="server" OnSelectedIndexChanged="ddl_OnSelectedIndexChanged">
    <asp:ListItem .../>

And in code behind:

Protected Sub ddl_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ddl.SelectedIndexChanged
End Sub

rknealAuthor Commented:
Shank - What you have does work but I get a prompt when I click an item from the drop down.  The prompt says

"Javascript: A script has requested that a new URL be loaded.  Do you wish to load http://XXX.XX"

This happens on a blackberry browser.  If I click Yes, it opens the page but if I can get fix this prompt then that would be all I need.  Any ideas?
rknealAuthor Commented:
Works to accomplish what I want but I have to find out a way around an annoying prompt.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.