SharePoint Page Layout Error: Only Content controls are allowed directly in a content page that contains Content controls

http://blogs.msdn.com/b/saurabhkv/archive/2009/10/13/sharepoint-page-layout-error-only-content-controls-are-allowed-directly-in-a-content-page-that-contains-content-controls.aspx

 

I recently built a SharePoint feature to provision custom master pages and page layouts for a client.  Overall the solution worked pretty well until one day, while making changes to one of the page layouts, I saw the following error: Only Content controls are allowed directly in a content page that contains Content controls.

Since other blog entries, referenced at the end of this article, can explain the background I'll get right to the cause and the solution.  The cause is improper case for the <asp:Content> control tags in my page layout.  A few contorls used a lower case "c" instead of an uppercase "C" in the word content.  The page layout that had trouble had tags that looked like: <asp:content> instead of <asp:Content>.  The specific offending tag is the one associated with the page title (<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">).  The solution was as simple as correcting the case of the tag name and all worked well.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个错误是因为在旧版本的C语言中,for循环中的变量声明只能在函数开头进行,而在C99标准中,可以在for循环中进行变量声明。解决方法是将编译器的标准设置为C99,可以在编译命令中加入参数“-std=c99”。 ### 回答2: 这个错误提示是在使用for循环时出现的,意思是“for循环初始化的声明只允许在c99模式下使用”。那么,什么是c99模式? c99模式是指在C语言标准的1999年修订版中增添的一些新特性,例如允许在for循环中声明变量。在之前的C语言标准中,变量必须先在函数的开头或者其他作用域的开头声明并初始化,然后才能在for循环中使用。而在c99模式下,可以直接在for循环中初始化变量,使得代码更加简洁易懂。 所以,如果出现“for循环初始化的声明只允许在c99模式下使用”的错误提示,可能是因为代码使用的是较旧的C语言标准,而尝试在for循环中初始化变量,导致编译器产生了错误。要解决这个问题,可以通过以下几种方法之一: 1. 使用更新的C语言标准。如果你的开发环境支持c99或者更高的标准,可以在编译命令中添加参数“-std=c99”或“-std=c11”来指定使用c99或c11标准。 2. 将变量的初始化放在for循环外面。虽然这样会使得代码更加繁琐,但是可以避免这个错误提示。 3. 将代码中的for循环改写成while循环。while循环不需要在循环头部声明和初始化变量,因此可以避免这个错误提示。 总之,这个错误提示的原因是因为尝试在for循环中初始化变量,但是使用的C语言标准不支持这种操作。要解决这个问题,可以使用c99标准或者其他方法。 ### 回答3: 这个错误提示是在编译C语言代码时出现的,通常是因为使用了C99标准中引入的一个特性——在for循环中允许在声明循环变量的同时进行初始化。然而,在旧版本的C语言标准中,这种语法是不允许的,因此就会出现上述错误提示。 要解决这个问题,有几种方法可以尝试: 1.将代码中的for循环改写为旧版本的语法形式: 例如,将以下代码: for (int i = 0; i < n; i++) { // 循环体 } 改写为: int i; for (i = 0; i < n; i++) { // 循环体 } 这样就可以避免使用C99特性,从而解决编译错误。 2.修改编译器选项,使其使用C99标准进行编译: 如果需要保留原本的for循环语法形式,也可以使用编译器选项来指定使用C99标准进行编译。例如,GCC编译器可以使用以下选项来开启C99支持: gcc -std=c99 ... 这样就可以在代码中使用C99标准中引入的新特性,而不会出现错误提示。 3.升级编译器版本: 如果使用的编译器版本过旧,可能会不支持C99标准中引入的新特性,因此出现编译错误。此时,可以尝试升级编译器版本,以便同时支持旧版本和C99标准中的新特性。 总之,在编写C语言代码时,需要根据实际情况选择适合的语法形式和编译器版本,避免出现编译错误和其他不必要的问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值