【问题标题】:The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel无法修改 Controls 集合,因为该控件包含代码块(即 <% ... %>)。Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel
【发布时间】:2014-05-15 01:10:01
【问题描述】:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +8668018
   Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +133

[HttpException (0x80004005): Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.]
   Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +181
   Telerik.Web.UI.RadAjaxControl.PerformRender() +375
   Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer, Control page) +1222
   Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +95
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266

【问题讨论】:

    标签: javascript c# html asp.net telerik


    【解决方案1】:

    你也可以在不使用telerik的情况下遇到这个问题,更好的解决方案是添加一个

    palceholder 代替 RadCodeBlock 适合所有情况

        <asp:PlaceHolder ID="PlaceHolder1"
    your script 
    
     runat="server"></asp:PlaceHolder>
    

    【讨论】:

      【解决方案2】:

      如果您在页面中使用“ 或 ”,通常会发生这种情况,您需要使用 RadcodeBlock

      例子:

      <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            //your script
         </telerik:RadCodeBlock>
      

      【讨论】:

      • link 对于遇到此问题的人。
      【解决方案3】:

      在我的例子中,我在 ASPX 页面中只有几个 if-else 块,如下所示。

      <%if (showControl)
      {%>
           <%--HTML Markup--%>
      <%}%>
      

      我将每个都包裹在 RadCodeBlock 中,错误就消失了。

      <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
      <%if (showControl)
      {%>
          <%--HTML Markup--%>
      <%} %>
      </telerik:RadCodeBlock>
      

      必须将每个这样的块包装在 RadCodeBlock 中。尝试包装整个 html 正文,但没有奏效。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-08
        • 2011-06-27
        相关资源
        最近更新 更多