Connecting Tech Pros Worldwide Help | Site Map

DropDownList MasterPage Error Navigate To URL erro help.

 
LinkBack Thread Tools Search this Thread
  #1  
Old June 19th, 2007, 01:10 AM
Newbie
 
Join Date: Mar 2007
Posts: 20
Default 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"
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">

<form id="frmNav" runat="server">
&nbsp;


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

</form>


<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"
/></div>



</asp:Content>
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.