none
Strange behaviour when upload Page layout to sharepoint RRS feed

  • Question

  • Hello,

    •  I have a Layout Page in Visual studio .
    • I use Module to upload Page layout in share point .
    • Then I activate the feature to upload it.
    • I create a page an attach this layout it , But I get the following error :

                 "Only Content controls are allowed directly in a content page that contains Content controls."

    • I download the page layout from master page gallery and check the HTML of it .
    • I found the following tags at the end of the page , And I don't where they are come from :

    <asp:content contentplaceholderid="PlaceHolderMain" runat="server">

    </asp:content>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"><head>
    <!--[if gte mso 9]><xml>
    <mso:CustomDocumentProperties>
    <mso:PublishingPreviewImage msdt:dt="string">~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/WelcomeSplash.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/WelcomeSplash.png</mso:PublishingPreviewImage>
    <mso:Title msdt:dt="string">Home Layout</mso:Title>
    <mso:ContentType msdt:dt="string">$Resources:cmscore,contenttype_pagelayout_name;</mso:ContentType>
    <mso:PublishingAssociatedContentType msdt:dt="string">;#Welcome Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4;#</mso:PublishingAssociatedContentType>
    </mso:CustomDocumentProperties>
    </xml><![endif]-->
    <title>Home Layout</title></head>

            How Can I solve this problem ?

             

    ASk

    Monday, April 7, 2014 7:24 AM

All replies

  • Hi,

    I would suggest you check whether you have configured properly when creating this page layout in Visual Studio.

    Here are two links about creating a page layout in Visual Studio for your reference:

    http://www.sharepointpals.com/post/How-to-Create-a-Page-Layout-(PageLayout)-with-ContentType-in-SharePoint-2013

    http://blogs.msdn.com/b/kaevans/archive/2011/04/02/code-behind-page-layouts-with-visual-studio-2010.aspx

    Best regards


    Patrick Liang
    TechNet Community Support

    Friday, April 11, 2014 9:23 AM
    Moderator
  • Hi Himo,<o:p></o:p>

    I am not sure that my solution will work for you but many a times when you trust on other people you feel betrayed. So here some time we as a developers feel over confidant on some tools but truth is we should not blindly faith on tools. They work perfectly in one case but their impact will break functionalities in other case.<o:p></o:p>

    I have gone through the code you posted:<o:p></o:p>

    <asp:content contentplaceholderid="PlaceHolderMain" runat="server"><o:p></o:p>

    </asp:content><o:p></o:p>

    If I am not wrong you must have use Visual Studio default formatting tool so that code get properly formated. But Visual studio changed it because of which its not working after deployment.<o:p></o:p>

    It should looks like below:<o:p></o:p>

    <asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server"><o:p></o:p>

    </asp:Content><o:p></o:p>

    Notice that lower case letters should be replaced with upper case. May be this makes your code work.<o:p></o:p>

    All the best. Please mark my answer as working and also revert in case it works for you.<o:p></o:p>

    Thanks<o:p></o:p>

    Friday, April 11, 2014 10:07 AM
  • Hello,

     Thanks for your reply .  I have send HTML of layout because I have not got the error yet

      <%@ Page Language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=15.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>

    <%@ Register TagPrefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <asp:content contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
    <SharePointWebControls:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Themable/Core Styles/pagelayouts15.css %>" runat="server"/>
    <PublishingWebControls:EditModePanel runat="server">
    <!-- Styles for edit mode only-->
    <SharePointWebControls:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Themable/Core Styles/editmode15.css %>"
    After="<% $SPUrl:~sitecollection/Style Library/~language/Themable/Core Styles/pagelayouts15.css %>" runat="server"/>
    </PublishingWebControls:EditModePanel>
    </asp:content>
    <asp:content contentplaceholderid="PlaceHolderPageTitle" runat="server">
    <SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/>
    </asp:content>
    <asp:content contentplaceholderid="PlaceHolderMain" runat="server">
    <WebPartPages:SPProxyWebPartManager runat="server" id="spproxywebpartmanager"></WebPartPages:SPProxyWebPartManager>
    <p></p>
    <div class="floatingDiv">
        <a href="" class="feedbackIcon"></a>
    </div>

    <div class="headerWrapper" id="top">
        <div class="menuWrapper">
            <WebPartPages:WebPartZone id="TopMenuZone" runat="server" title="Top Menu Zones"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
            </div>
        </div>
    <div class="containerWrapper">
       <WebPartPages:WebPartZone id="SliderZone" runat="server" title="Slider Zones"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

         <div class="newsNSocialWrapper">
               <WebPartPages:WebPartZone id="NewsSocialZone" runat="server" title="News And Social Zones"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
            </div>

       <div class="SectionContainer">
            <WebPartPages:WebPartZone id="HorizontalMenuZone" runat="server" title="Horizontal Menu Zones"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
        </div>

        <div class="clear"></div>
          <div class="leftPanel">
              <div class="EventList">
               <WebPartPages:WebPartZone id="EventListZone" runat="server" title="Event List Zone"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
        </div>
              <div class="horLine"></div>
              <div class="MediaList">
              <WebPartPages:WebPartZone id="IconsZone" runat="server" title="Icons Zones"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
              </div>
          </div>
          <div class="rightPanel">
          <div class="ColContainer">
            <WebPartPages:WebPartZone id="CloudTagsZone" runat="server" title="Cloud tags Zones"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
            </div>
            <div class="ColContainer">
            <WebPartPages:WebPartZone id="PrayerTimesZone" runat="server" title="Prayer Times Zones"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
            </div>
                   
          </div> 
          <div class="clear"></div>

    </div>


    <div class="footerWrapper">
        <a href="#top" class="go2TopLink"></a>
        <div class="footer">
            <div class="quickLinks">
                <WebPartPages:WebPartZone id="FooterZone" runat="server" title="Fooer Zone"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
            </div>
            <div class="appsNsocial">
                <h1><span id="downloadsSpan">Downloads</span></h1>
                <div class="clear5"></div>
                <a href="#" title="Download Dhofar Tourism Android Application from Google Play" class="GPlay" target="_blank"></a>
                <a href="#" title="Download Dhofar Tourism Android Application from Apple App Store" class="iApp" target="_blank"></a>
            </div>
            <div class="copyRight">
                <div class="dhofarLogo"></div>
                <div class="clear5"></div>
                <a href="http://omantourism.gov.om/" title="link to Oman Tourism Website" target="_blank"><span id="rightsSpan">Copyright © 2014 Ministry of Tourism, Sultanate of Oman</span></a>
            </div>
        <div class="clear"></div>
        </div>
    </div>
    </asp:content>

    ASk

    Monday, April 14, 2014 6:29 AM
  • Without being able to trace what SharePoint is doing in its Item Adding/Added event receivers on the gallery, I can only guess at what is going on.  It appears as if the page is compiled and there is a page compilation exception during the item add/update event on the ASPX item.  In this situation, SharePoint will modify the ASPX file and insert the following to the end of your file:

    • Microsoft.SharePoint.WebControls namespace registration
    • html element
    • head element
    • mso comments
    • title element

    This added content is what is throwing the exception for you when you use it; you can only have Content tags in the root of a content page.  Why SharePoint is adding this content I don't know.  Maybe compiling the page is its way, regardless of file extension, of knowing is this is an HTML design file or a real ASPX page layout.  Perhaps it assumes any page with an exception in compilation is an HTML design file.

    So, the other poster from April 11, 2014 (mohitvash) was correct in a sense.  Your page is getting a compilation exception because asp:content is not correct.  The "Content" part of the tag is a class name and as such it is case sensitive.  It needs to be asp:Content.

    My guess is that you copied an existing ASPX page layout file to build yours.  This is how I got the problem, but in my investigation I have been unable to download any of the ASPX pages (mine, theirs, or HTML designed copies) and get lowercase Content tags.  I just cannot reproduce it anymore.  Well, no matter.  Now we know how to fix it when it does happen again.

    Happy coding!!

    _Alex


    _Alex

    Friday, July 25, 2014 3:16 AM