dropdownlist --> URL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Web form VS 2005...

DropDownList has text describing links and url's.

What I want to do is have the DropDownList1.SelectedIndexChanged event
perform a hyperlink to the Value in the control at the selected index
position.

I've looked high and low for an example of this under ASP.NET 2.0 but have
yet to find any thing close. What VB function do I use in the code behind
page event to trigger the lauch of a new instance of the browser to the url
specified in the index value of the DropDownList control?
 
Ken said:
Web form VS 2005...

DropDownList has text describing links and url's.

What I want to do is have the DropDownList1.SelectedIndexChanged event
perform a hyperlink to the Value in the control at the selected index
position.

I've looked high and low for an example of this under ASP.NET 2.0 but have
yet to find any thing close. What VB function do I use in the code behind
page event to trigger the lauch of a new instance of the browser to the url
specified in the index value of the DropDownList control?

I believe you will need to do this in javascript on the client side.
The server can not spawn a new instance of the browser.

chris
 
Some code to get you going...

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then

Dropdownlist1.Attributes("onChange") = "doJump('" &
Dropdownlist1.ClientID & "');"


End If
End Sub



<script language="javascript">
<!--

function doJump(theID) {
var theElement = document.getElementById(theID);
var si = theElement.selectedIndex;
if (si > 0) {
theElement.selectedIndex = 0; //reset menu to default
window.location.href = theElement.options[si].value;
}
}

-->
</script>

<form id="Form1" method="post" runat="server">
....
<asp:dropdownlist id="Dropdownlist1" Runat="server"></asp:dropdownlist>
....
</form>

Greg
 
Back
Top