" />

Errors with <% %>

3 posts, 0 answers
  1. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 08 May 2012 Link to this post

    I am trying to put some simple code in a label tag and I get this error (Sorry for the french language):

    Erreur du serveur dans l'application '/'.

    La collection Controls ne peut pas être modifiée, car le contrôle contient des blocs de code (c'est-à-dire <% ... %>).

    Description : Une exception non gérée s'est produite au moment de l'exécution de la demande Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code. 

    Détails de l'exception: System.Web.HttpException: La collection Controls ne peut pas être modifiée, car le contrôle contient des blocs de code (c'est-à-dire <% ... %>).

    Erreur source: 

    Une exception non gérée s'est produite lors de l'exécution de la demande Web actuelle. Les informations relatives à l'origine et l'emplacement de l'exception peuvent être identifiées en utilisant la trace de la pile d'exception ci-dessous.

    Trace de la pile: 

    [HttpException (0x80004005): La collection Controls ne peut pas être modifiée, car le contrôle contient des blocs de code (c'est-à-dire <% ... %>).]
       System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +8689794
       Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +215
    
    [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) +280
       Telerik.Web.UI.RadAjaxControl.PerformRender() +508
       Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer, Control page) +1800
       Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +163
       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
    


    Informations sur la version : Version Microsoft .NET Framework :2.0.50727.5448; Version ASP.NET :2.0.50727.5456
     

    What I am trying to do:

    <label><% Response.Write(GetMessageEx(5908, MessageFile.GesPhar).Texte)%></label>

    Can someone tell me how to resolve this ? 

    Thanks.
  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 08 May 2012 Link to this post

    Hello,

    I recommend that you review RadCodeBlock and RadScriptBlock help article which elaborates on this subject.

    Greetings,

    Pavlina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 11 May 2012 Link to this post

    Thank you Pavlina.

    I have another question: Do I have to put each <% %> between CodeBlock or I could put my entire asp page between CodeBlock? I mean, what is the right way to do this? I'm trying to put my code as clear as I can.

    I mean should I do:

                    <telerik:RadCodeBlock ID="RadCodeBlock3" runat="server">
                        <label class="linedCtrl">
                            <% =GetMessageEx(4661, MessageFile.GesPhar).Texte%></label>
                        <telerik:RadTextBox ID="txtNoDossier" runat="server" ReadOnly="true">
                        </telerik:RadTextBox>
                        <label class="linedCtrl">
                            <% =GetMessageEx(5889, MessageFile.GesPhar).Texte%></label>
                        <telerik:RadTextBox ID="txtNoAdmission" runat="server" ReadOnly="true">
                        </telerik:RadTextBox>
                    </telerik:RadCodeBlock>
    ...
                    <telerik:RadCodeBlock ID="RadCodeBlock4" runat="server">
                        <label class="linedCtrl">
                            <% =GetMessageEx(4661, MessageFile.GesPhar).Texte%></label>
                        <label class="linedCtrl">
                            <% =GetMessageEx(5889, MessageFile.GesPhar).Texte%></label>
                    </telerik:RadCodeBlock>

    Or my entire page:

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="MedicActive.aspx.vb" Inherits="GESPHARxLite_2.MedicActive" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Charting" TagPrefix="telerik" %>
     
    <script src="Scripts/jquery-1.7.min.js" type="text/javascript"></script>
    <script src="Scripts/Resizer.js" type="text/javascript"></script>
     
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadCodeBlock ID="RadCodeBlock3" runat="server">
                Some asp code...
        </telerik:RadCodeBlock>
        </form>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
     
            <script type="text/javascript">
                
            </script>
     
        </telerik:RadCodeBlock>
    </body>
    </html>

    Thanks.
Back to Top