Open a new webpage from a Dropdown List item

B

Brian Reaburn

Hi,

I'm looking for some help. I would like to know how to launch a new IE
browser window when I select an item from a dropdown list. I know this is
possible I've seen many examples of where people have done it, but I can't
find any information on how.

I'm using VB as my page language. Thanks in advance...

Brian
 
K

Ken Cox [Microsoft MVP]

Hi Brian,

Here's one way to do it...

Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles DropDownList1.SelectedIndexChanged
Page.RegisterStartupScript _
("opnpg", "<script>window.open('" & _
DropDownList1.SelectedItem.Value & _
"','_blank');</script>")

End Sub

<form id="Form1" method="post" runat="server">
<asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem
Value="http://msdn.microsoft.com">http://msdn.microsoft.com</asp:ListItem>
<asp:ListItem
Value="http://www.aspalliance.com/kenc">http://www.aspalliance.com/kenc</asp:ListItem>
</asp:DropDownList>
</form>

Does this help?

Ken
Microsoft MVP [ASP.NET]
http://weblogs.asp.net/kencox
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top