472,119 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

DropDownList MasterPage Error Navigate To URL erro help.

I hope someone can help me. I have an error that I can not seem to figure out. All I need is an unbound dropdownlist to navigate to urls withing the website. I have gotten as far as to populate field but I am stuck at this point. I am new to asp.net and this is my first website.

Below is my code please help.

Content controls have to be top-level controls in a content page or a nested master page that references a master page.

This is the error

HttpException (0x80004005): Content controls have to be top-level controls in a content page or a nested master page that references a master page.] System.Web.UI.MasterPage.CreateMaster(TemplateCont rol owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +533 System.Web.UI.Page.get_Master() +49 System.Web.UI.Page.ApplyMasterPage() +17 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1368
This error seems to indicate that the way I have placed the code is incorrect but I am unsure how to format it correctly.

Here is the code below
<%@ 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/CreateAccount.aspx"))
myLocations.Add(New ListItem("FAQS"))

' 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(ByVal sender As Object, ByVal e As EventArgs)
End Sub


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1">

<form id="frmNav" runat="server">

<asp:literal id="litAutoNavLink" runat="server" />


<div style="right: -342px; width: 359px; position: relative; top: -83px; height: 44px">

<asp:DropDownList id="ddlLocations" runat="server" style="position: relative" Width="201px" />

<asp:Button id="btnGo" runat="server"
Text = "Go"
OnClick = "btnGo_Click" style="position: relative"

Jun 19 '07 #1
0 2363

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Michael | last post: by
9 posts views Thread by Lammert | last post: by
2 posts views Thread by needin4mation | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.