Menu control in Master page wont display throughout the site

2.4k Views Asked by At

I have a very weird/interesting thing that is happening on one of my ASP.NET Web Forms projects. I have created a master page and formatted the layout using CSS. In this layout I've included a Menu navigation control using the Web.config file as the datasource (duh). When I compile and run the project, the Default.aspx works fine. The Menu control displays the appropriate links as specified in the Web.config file.

Here's the weird part. When I create new pages from the master page, everything works as expected except for the Menu control. It isn't there. I'm at a loss. I've dibbled and dabbled with so many things now that I think my brain is fried. Any suggestions will be greatly appreciated.

Thanks

1

There are 1 best solutions below

0
On

Try this:

Example Master page:

<head runat="server">
//place your CSS style on resolve URL 
<link href="<%# ResolveUrl("~/style.css") %>" rel="stylesheet" type="text/css" />
</head>
<form id="form1" runat="server">

    <div id="container">

        <div id="menunav">
          //place your menu here
        </div>

            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

            </asp:ContentPlaceHolder>
    </div>

 </form>

Then on your master page load event: Add

 Page.Header.DataBind();

Example Child Page:

 <%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="MyWebApp.WebForm1" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

     //Your child page Stuff

</asp:Content>

Hope this help.

Regards