ASP 101 - Active Server Pages 101 pulldown_nav.aspx
<%@ Page Language="VB" %>
<script language="VB" runat="server">
	Sub Page_Load(sender As Object, e As EventArgs)
		Dim blnAutoNav As Boolean
		If Not Page.IsPostBack Then
			' Create a new ListItemCollection
			Dim myLocations As New ListItemCollection()
			' Add items to the collection
			myLocations.Add(New ListItem("Where do you want to go?", Request.ServerVariables("URL")))
			myLocations.Add(New ListItem("Code description and download", ""))
			myLocations.Add(New ListItem("View the live source code", ""))
			myLocations.Add(New ListItem("ASP 101 home page", ""))
			' Databind our DDL to the ListItemCollection we just filled
			ddlLocations.DataSource     = myLocations
			ddlLocations.DataTextField  = "Text"
			ddlLocations.DataValueField = "Value"
		End If
		' Find out current auto-navigation status and add JS to handle it if needed.
		If Request.QueryString("auto") = "True" Then
			blnAutoNav = True
			' This adds the javascript to automatically redirect to the selected
			' location whenever a new item is selected in the dropdownlist.
			ddlLocations.Attributes("onchange") = "javascript:window.location = " _
				& "document.frmNav.ddlLocations[document.frmNav.ddlLocations.selectedIndex].value;"
			blnAutoNav = False
		End If			
		' Add the link to this page that toggles the autonav to
		' the opposite of its current setting.
		litAutoNavLink.Text = "<a href=""" & Request.ServerVariables("URL") _
			& "?auto=" & CStr(Not(blnAutoNav)) & """>Toggle Auto Navigation</a>"
	End Sub
	Sub btnGo_Click(sender As Object, e As EventArgs)
	End Sub
<title>ASP.NET DropDownList Navigation Sample</title>
<form id="frmNav" runat="server">
<asp:DropDownList id="ddlLocations" runat="server" />
<asp:Button id="btnGo" runat="server"
	Text    = "Go"
	OnClick = "btnGo_Click"
<asp:literal id="litAutoNavLink" runat="server" />
<hr />
Click <a href="">here</a>
to read about and download the source code.