Thursday, March 22, 2012

Open a new webpage from a Dropdown List item

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...

BrianHi 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

"Brian Reaburn" <reaburn.brian@.colteng.com> wrote in message
news:euLaJJyREHA.3012@.tk2msftngp13.phx.gbl...
> 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

0 comments:

Post a Comment