Subscribe
E-mail
Download View Codeplex Project Site
Powered by: newtelligence dasBlog 1.9.7174.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Rich Finn
dasBlog MOSS template
After working in my local development environment for a few days, I was ready to deploy a Solution Package containing some publishing layout pages into our testing environment.Once the solution deployment was complete, I tested one of the four page layouts by creating a new publishing page. Immediately, the page rendered with the error 'Only Content controls are allowed directly in a content page that contains Content controls.' I thought, weird, it works on my machine, so I went and checked out the Pages list in the Web. The page had been created correctly, and I could view the properties, so what's the deal?
Then I went to the Page Settings page via the URL, and changed the Page Layout to one of the other three page layouts in my Solution Package - no luck. Went back and tried it with a third page layout, and to my surprise, it rendered without any issues or errors. The fourth one worked, too. I actually saw this as bad news since I couldn't blame the issue on anyone or anything but myself - or so I thought. Remember, it worked on my machine!
I assumed the problem had to be something similar in the two page layouts, which were only markup, so I slowly tried whittling away pieces of markup to hopefully find the offending tag. This was a brutally painful process because since I wasn't receiving the error locally, I had to build the .wsp, move it to test, deploy it, and run the page. Each change and deployment took around 15-20 minutes - ouch.
After a few hours of trying this method with no luck, I wondered if the code was even being updated in SharePoint since I was using both the -removesolution/-deploysolution and the -upgradesolution methods. The solution packages seemed to be getting deployed successfully and my page layouts were showing code changes in the FEATURES folder, so I went to the Master Page Gallery to see if the code was getting updated in the server.
Luckily, you can download copies of aspx pages from the Master Page Gallery just like they were any other kind of document by clicking the drop down for the document and choosing Send to > Download a copy.
When I viewed the markup of the page, I noticed that the code hadn't changed since the initial deployment! Normally, when you upgrade a solution, it does, so I was confused. As I looked through the source a little further, I noticed at the bottom a strange snippet just after the closing tag for the last Content tag:
</asp:Content> <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:ContentType msdt:dt="string">Page Layout</mso:ContentType> <mso:PublishingAssociatedContentType msdt:dt="string">;#Custom Page Layout Content Type; #0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE81100 2D7E961EBCD042C6A40B97F107579F70;#</mso:PublishingAssociatedContentType> </mso:CustomDocumentProperties> </xml><![endif]--> <title>PageLayoutTitle</title></head>
Hey - those are the properties I set when I provision the files into the Master Page Gallery on activation of the feature! Well, that explains the Content controls error, but why is it in there? And, why isn't the code being updated on upgrade of the solution package?I thought that maybe I could just delete the two offending page layouts, upgrade the solution package again, and the page layouts will be replaced. I deleted the page I created using the page layout, then went to delete them from the Master Page Gallery. Another error! This time, it was the 'This item cannot be deleted because it is still referenced by other pages' error.
After searching around, I came across Katrien De Graeve's blog which explains a nice hack for removing pages from the Gallery when you see this error. Once the pages were gone, I was able to re-upgrade the solution package, but I was still seeing the Content controls error, and the properties were still being inserted into the page markup.
Opening the page layout in SharePoint Designer proved to be some help. I was able to remove the properties from the bottom of the page, save it, and it rendered without any errors. That helped a little, but not if I have to do that every time I deploy the code.
I took the markup of one of the working page layouts in the solution package and replaced the markup of the one of the broken page layouts. It worked! I slowly started piecing the page layout back together by pasting in little sections at a time until I found the offending markup. By the time all the markup was back in there, I had seen no errors.
So - this leads me to believe that there was something imbedded into the page that I couldn't see which was causing the error. Pasting the code in fixed whatever it was. I'm assuming that I could have easily just pasted all the markup into Notepad, and then back into the Visual Studio editor, too, saving a ton of time. If you have any ideas on what it could have been, please let me know.
Update (9/7/2007): Found that for some reason, one of the <asp:Content> controls became lowercase somehow, as in <asp:content>. As soon as the casing was fixed, worked like a champ...