Master Page Weirdness - “Content controls have to be top-level controls in a content page or a nested master page that references a master page.”

后端 未结 13 1789
借酒劲吻你
借酒劲吻你 2020-12-05 06:28

This is weird. I added a brand new Web Application project to my solution in Visual Studio 2008.

Created a master page. Made zero modifications. Created a new we

相关标签:
13条回答
  • 2020-12-05 06:41

    I encountered this error after editing a web part (.aspx) page in SharePoint Designer 2013. When I looked at the code in SPD, an H1 element near the top of the page was highlighted yellow. Hovering over that indicated that SharePoint:AjaxDelta was not closed before the H1. Adding the </SharePoint:AjaxDelta> fixed it.

    Weird because it appeared SPD introduced the error after I was working on listview web parts or a page viewer web part elsewhere on the page.

    0 讨论(0)
  • 2020-12-05 06:45

    In my case I was loading a user control dynamically in a page and both the page and user control had the content tags

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

    Removing this tag from the user control worked for me.

    0 讨论(0)
  • 2020-12-05 06:50

    Here's another way using Visual Studio: If you do New Item in Visual Studio and you select Web Form, it will create a standalone *.aspx web form, which is what you have for your current web form (is this what you did?). You need to select Web Content Form and then select the master page you want attached to it.

    0 讨论(0)
  • 2020-12-05 06:53

    Your web form shouldn't have all of that markup (like the <html> tag). Since it has a master page, you just start with the content tag. Your aspx page should look like this:

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebUI._Default" MasterPageFile="~/Site1.Master" %>
    
    <asp:content id="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
       This is the body!
    </asp:content>
    

    When you're adding a new aspx page make sure to check "select master page" in the "add new item" dialog.

    0 讨论(0)
  • 2020-12-05 06:53

    You need to add asp content and add content place holder id correspond to the placeholder in master page.

    You can read this link for more detail

    0 讨论(0)
  • 2020-12-05 06:56

    Your web form should look like this:

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebUI._Default" MasterPageFile="~/Site1.Master" %>
    <asp:Content runat="server" ID="head" ContentPlaceHolderId="head">
    <!-- stuff you want in &gt;head%lt; -->
    </asp:Content>
    
    <asp:Content runat="server" ID="content" ContentPlaceHolderId="ContentPlaceHolder1">
    <h1>Your content</h1>
    </asp:Content>
    

    Note that there is no <html> tag

    0 讨论(0)
提交回复
热议问题