IT Specialist & Developer IT Specialist Personal Blog, Specialized in Information Security, Compliance, Business Development, and Active Software Developer
  • Using Navigation Master Page Creates issues

    I faced an issue while using Master Page for navigation through an ASP.NET site.

    Once I create the web form, and select the master page from porperties, a message will show up “the page contains markup that is not valid when attached to master page”.

    To get rid of this problem, in your aspx page you will need to remove all the html declarations added to the web form automatically by the Visual Studio, like the below listed code.

    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>

    <html xmlns=”http://www.w3.org/1999/xhtml“>
    <head runat=”server”>
    <title></title>
    </head>
    <body>
    <form id=”form1″ runat=”server”>
    <div>

    </div>
    </form>
    </body>
    </html>

    Using site navigation master page will override the default html tags in your aspx, files and use the content place holder to put the content.

    Make sure to place your content in the “content place holder” as follows:

    <asp:Content ID=”Content1″ runat=”server”
    contentplaceholderid=”ContentPlaceHolder1″>
    <p>
    Some more content here to show
    </p>
    </asp:Content>

    Just make sure that your aspx page contains only the page directive, then use the content place holder.

    Easier solution to use, while creating a new web form using Visual Studio, select “Web Form using Master Page” from the templates list provided by Visual Studio while adding new item.

    Navigation master page, is a master container to all your pages that will contain content within the design your specified in the master page.

    Published on May 1, 2011 · Filed under: IIS & ASP.NET; Tagged as:
    No Comments

Leave a Reply