Hi,
I have been trying to modify this code that I got from asp101.com
The basics of what I want is a combobox that navigates to different pages in website.
I have tried creating a combobox on my own but get stuck when trying to code the actual navigation in the web.
I tried modifying the below code but I get countless error when I try to build and now the combobox does not show at all in the page content. PLEASE HELP.
I am willing to modify the existing code or start fresh.
Below is the code that I am using on the page
<%@ Page Language="VB" MasterPageFile="~/MasterPage2.master" AutoEventWireup="true" Title="Welcome Guest"%>
<script language="VB" script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.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("Request Membership", "http://www.url.com/page.aspx"))
myLocations.Add(New ListItem("FAQS", "http://www.url.com/page.aspx"))
' Databind our DDL to the ListItemCollection we just filled
ddlLocations.DataSource = myLocations
ddlLocations.DataTextField = "Text"
ddlLocations.DataValueField = "Value"
ddlLocations.DataBind()
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;"
Else
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(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect(ddlLocations.SelectedItem.Value)
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1">
<body>
<form id="frmNav" runat="server">
<asp:DropDownList id="ddlLocations" runat="server" />
<asp:Button id="btnGo" runat="server"
Text = "Go"
OnClick = "btnGo_Click"
/>
<p>
<asp:literal id="litAutoNavLink" runat="server" />
</p>
</form>
<hr />
</body>
</asp:Content>