Get this error while using RadAsyncUpload in a aspx page using master page : The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

2 posts, 0 answers
  1. Mohammad
    Mohammad avatar
    2 posts
    Member since:
    Jun 2013

    Posted 20 Jun 2013 Link to this post

    Hi , I have a problem with the telerik ajax controls like this.

    I have this master page :
    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="Resource_Main" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
     
        <link href="/resource/main.css" type="text/css" rel="stylesheet" />
     
        <script src="/resource/js/jquery-2.0.0.js"></script>
        <script src="/resource/js/jquery-2.0.0.min.js"></script>
        <script src="/resource/js/jquery.json-2.2.min.js"></script>
     
        <title></title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
        <script>
            $(document).ready(function () {
                $("#loginPanel").hide();
     
     
     
                $("#btnlogin").on("click", function (event) {
                    $("#loginPanel").fadeToggle("fast", "swing");
                });
     
                $("#btnDoLogin").on("click", Login);
     
                $("#btnProfileMenu").on("click", function (event) {
                    $("#tdPbar").fadeToggle("fast", "swing");
                });
     
     
     
                if (sessionStorage.getItem("LOGINED") == "True") {
                    $("#btnlogin").hide("Slow");
                    $("#btnProfileMenu").show("fast")
                    $("#tdPbar").hide("fast");
                }
                else {
                    $("#btnProfileMenu").hide("fast");
                    $("#btnlogin").show("fast");
                    $("#tdPbar").hide("fast");
                }
     
            });
     
     
            function Login() {
                $("#loadingLogin").html("<img width='20px' src='/resource/img/loading141.gif' />");
     
                $.ajax({
     
                    type: "POST",
                    url: "default.aspx/login",
     
                    data: "{'User_name':'" + $("#<%=txtUser.ClientID%>").val() + "','User_Pass':'" + $("#<%=txtPass.ClientID%>").val() + "'}",
     
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: true,
                    cache: false,
                    success: function (msg) {
                        if (msg.d == 'true') {
                            $("#loadingLogin").html("<span class='msg'>Login successd,Redirecting ...</span>");
                            sessionStorage.setItem("LOGINED", "True");
                            sessionStorage.setItem("username", $("#<%=txtUser.ClientID%>").val());
                            document.location.href = '/default.aspx';
                        }
                        else {
                            $("#loadingLogin").html("<span class='error'>" + msg.d + "</span>");
                        }
     
                    }
     
                });
            }
     
        </script>
    </head>
    <body>
     
        <form id="form1" runat="server">
            <table style="width: 100%;" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="Header">
                        <table style="width: 100%;">
                            <tr>
                                <td style="width: 50px;"></td>
                                <td style="width: 170px;">
                                    <img src="/resource/img/Logo.png" /></td>
                                <td style="width: 825px;">
                                    <asp:TextBox ID="txtSearch" CssClass="txtSearch" runat="server"></asp:TextBox>
                                    <asp:Button ID="btnSearch" CssClass="btnSearch" runat="server" Text="              " />
                                </td>
                                <td>
                                    <input name="btnlogin" id="btnlogin" type="button" onclick="" class="btnLogin" value="Login" />
                                    <input name="btnProfileMenu" id="btnProfileMenu" type="button" onclick="" class="btnLogin" value="Profile" />
                                    <span name="loginPanel" id="loginPanel" class="LoginPanel">
                                        <table style="width: 100%;">
                                            <tr>
                                                <td style="width: 80px">Username :</td>
                                                <td>
                                                    <asp:TextBox ID="txtUser" runat="server" CssClass="publicTextBox" Width="90%"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Password :</td>
                                                <td>
                                                    <asp:TextBox ID="txtPass" runat="server" CssClass="publicTextBox" Width="90%" TextMode="Password"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" style="vertical-align: central">
                                                    <input name="btnDoLogin" id="btnDoLogin" type="button" onclick="" class="publicButton" value="Sing in" />
     
                                                    <span id="loadingLogin" name="loadingLogin" class="loadingLogin"></span></td>
                                            </tr>
                                        </table>
                                    </span>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td id="tdPbar" class="Header" colspan="4">
     
                        <table style="width: 100%;" cellpadding="0" cellspacing="0">
     
                            <tr>
     
                                <td>
                                    <asp:LinkButton ID="LinkButton2" runat="server" CssClass="LinkButtonProfileMenu">LinkButton</asp:LinkButton>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CssClass="LinkButtonProfileMenu" PostBackUrl="~/Upload.aspx">Upload</asp:LinkButton>
                                    <asp:LinkButton ID="lbtnMyChannel" runat="server" PostBackUrl="~/MyChannel.aspx" CssClass="LinkButtonProfileMenu">My Channel</asp:LinkButton></td>
     
                            </tr>
     
                        </table>
     
                    </td>
                </tr>
                <tr style="height:500px">
                    <td style="vertical-align:top">
                        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                        </asp:ContentPlaceHolder>
                    </td>
                </tr>
                <tr>
                    <td class="Footer">Copyright  2013-2014 by Video Arts Company</td>
                </tr>
            </table>
        </form>
    </body>
    </html>

    and i have a a page upload.aspx
    I'd like to use the RadAsyncUpload control in my page , i add a RadScriptManager and i register the Assembly of telerik in my web.config , but when run the page i receive this error :
    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    my upload.aspx is :
    <%@ Page Title="" Language="C#" MasterPageFile="~/Resource/Main.master" AutoEventWireup="true" CodeBehind="Upload.aspx.cs" Inherits="VartsTube.Upload" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js"></asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js"></asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js"></asp:ScriptReference>
            </Scripts>
        </telerik:RadScriptManager>
     
     
        <table class="tblUpload">
            <tr>
                <td class="tblUploadCenterTD">
                    <table class="tblUpload">
                        <tr>
                            <td class="tdUpload2">
                                <h3>Upload Video</h3>
                            </td>
                        </tr>
                        <tr>
                            <td class="tdUpload1">
                                <h5>Select Your Video </h5>
                                <p>
                                    <telerik:RadAjaxPanel ID="ajxpanelupload" runat="server" Height="200px" Width="300px">
                                        <telerik:RadAsyncUpload ID="uploader" runat="server"></telerik:RadAsyncUpload>
                                    </telerik:RadAjaxPanel>
                                </p>
     
                            </td>
                        </tr>
                        <tr>
                            <td class="tdUpload1">
                                <h5 style="direction: ltr; text-align: left">Title</h5>
                                <asp:TextBox ID="txtTitle" CssClass="txtTitle" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="tdUpload1">
                                <h5 style="direction: ltr; text-align: left">Description</h5>
                                <asp:TextBox ID="txtDesc" CssClass="txtTitle" runat="server" TextMode="MultiLine" Height="60px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="tdUpload3">
                                <input name="btnSubmiteUpload" id="btnSubmiteUpload" type="button" onclick="" class="publicButton" value="Submite" />
     
     
                            </td>
                        </tr>
                    </table>
                </td>
                <td></td>
            </tr>
        </table>
     
     
    </asp:Content>

    and this is my web.config :
    <?xml version="1.0"?>
    <configuration>
      <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
              <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
              <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
              <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
              <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            </sectionGroup>
          </sectionGroup>
        </sectionGroup>
      </configSections>
      <appSettings />
      <connectionStrings />
      <system.web>
        <compilation debug="true">
          <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Speech, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>
        <!--
                The <authentication> section enables configuration
                of the security authentication mode used by
                ASP.NET to identify an incoming user.
            -->
        <authentication mode="Windows" />
        <!--
                The <customErrors> section enables configuration
                of what to do if/when an unhandled error occurs
                during the execution of a request. Specifically,
                it enables developers to configure html error pages
                to be displayed in place of a error stack trace.
     
            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
        <pages>
          <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </controls>
        </pages>
        <httpHandlers>
          <remove verb="*" path="*.asmx" />
          <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
          <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
        </httpHandlers>
        <httpModules>
          <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </httpModules>
      </system.web>
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="WarnAsError" value="false" />
          </compiler>
        </compilers>
      </system.codedom>
      <!--
            The system.webServer section is required for running ASP.NET AJAX under Internet
            Information Services 7.0.  It is not necessary for previous version of IIS.
        -->
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules>
          <remove name="ScriptModule" />
          <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </modules>
        <handlers>
          <remove name="WebServiceHandlerFactory-Integrated" />
          <remove name="ScriptHandlerFactory" />
          <remove name="ScriptHandlerFactoryAppServices" />
          <remove name="ScriptResource" />
          <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
        </handlers>
      </system.webServer>
      <runtime>
        <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>


    how can i fix it ?

    Thank's a lot if you reply ASAP....
  2. Mohammad
    Mohammad avatar
    2 posts
    Member since:
    Jun 2013

    Posted 21 Jun 2013 Link to this post

    I solve my problem with this change in Master Page :
    I move the script tag from the head to out of head :

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="Resource_Main" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
     
        <link href="/resource/main.css" type="text/css" rel="stylesheet" />
     
        <script src="/resource/js/jquery-2.0.0.js"></script>
        <script src="/resource/js/jquery-2.0.0.min.js"></script>
        <script src="/resource/js/jquery.json-2.2.min.js"></script>
     
        <title></title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
         
    </head>
     
     
        <%-- I move the script tag from the head to here --%>
        <script>
            $(document).ready(function () {
                $("#loginPanel").hide();
     
     
     
                $("#btnlogin").on("click", function (event) {
                    $("#loginPanel").fadeToggle("fast", "swing");
                });
     
                $("#btnDoLogin").on("click", Login);
     
                $("#btnProfileMenu").on("click", function (event) {
                    $("#tdPbar").fadeToggle("fast", "swing");
                });
     
     
     
                if (sessionStorage.getItem("LOGINED") == "True") {
                    $("#btnlogin").hide("Slow");
                    $("#btnProfileMenu").show("fast")
                    $("#tdPbar").hide("fast");
                }
                else {
                    $("#btnProfileMenu").hide("fast");
                    $("#btnlogin").show("fast");
                    $("#tdPbar").hide("fast");
                }
     
            });
     
     
            function Login() {
                $("#loadingLogin").html("<img width='20px' src='/resource/img/loading141.gif' />");
     
                $.ajax({
     
                    type: "POST",
                    url: "default.aspx/login",
     
                    data: "{'User_name':'" + $("#<%=txtUser.ClientID%>").val() + "','User_Pass':'" + $("#<%=txtPass.ClientID%>").val() + "'}",
     
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: true,
                    cache: false,
                    success: function (msg) {
                        if (msg.d == 'true') {
                            $("#loadingLogin").html("<span class='msg'>Login successd,Redirecting ...</span>");
                            sessionStorage.setItem("LOGINED", "True");
                            sessionStorage.setItem("username", $("#<%=txtUser.ClientID%>").val());
                            document.location.href = '/default.aspx';
                        }
                        else {
                            $("#loadingLogin").html("<span class='error'>" + msg.d + "</span>");
                        }
     
                    }
     
                });
     
            }
     
        </script>
    <body>
     
        <form id="form1" runat="server">
            <table style="width: 100%;" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="Header">
                        <table style="width: 100%;">
                            <tr>
                                <td style="width: 50px;"></td>
                                <td style="width: 170px;">
                                    <img src="/resource/img/Logo.png" /></td>
                                <td style="width: 825px;">
                                    <asp:TextBox ID="txtSearch" CssClass="txtSearch" runat="server"></asp:TextBox>
                                    <asp:Button ID="btnSearch" CssClass="btnSearch" runat="server" Text="              " />
                                </td>
                                <td>
                                    <input name="btnlogin" id="btnlogin" type="button" onclick="" class="btnLogin" value="Login" />
                                    <input name="btnProfileMenu" id="btnProfileMenu" type="button" onclick="" class="btnLogin" value="Profile" />
                                    <span name="loginPanel" id="loginPanel" class="LoginPanel">
                                        <table style="width: 100%;">
                                            <tr>
                                                <td style="width: 80px">Username :</td>
                                                <td>
                                                    <asp:TextBox ID="txtUser" runat="server" CssClass="publicTextBox" Width="90%"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Password :</td>
                                                <td>
                                                    <asp:TextBox ID="txtPass" runat="server" CssClass="publicTextBox" Width="90%" TextMode="Password"></asp:TextBox></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" style="vertical-align: central">
                                                    <input name="btnDoLogin" id="btnDoLogin" type="button" onclick="" class="publicButton" value="Sing in" />
     
                                                    <span id="loadingLogin" name="loadingLogin" class="loadingLogin"></span></td>
                                            </tr>
                                        </table>
                                    </span>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td id="tdPbar" class="Header" colspan="4">
     
                        <table style="width: 100%;" cellpadding="0" cellspacing="0">
     
                            <tr>
     
                                <td>
                                    <asp:LinkButton ID="LinkButton2" runat="server" CssClass="LinkButtonProfileMenu">LinkButton</asp:LinkButton>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CssClass="LinkButtonProfileMenu" PostBackUrl="~/Upload.aspx">Upload</asp:LinkButton>
                                    <asp:LinkButton ID="lbtnMyChannel" runat="server" PostBackUrl="~/MyChannel.aspx" CssClass="LinkButtonProfileMenu">My Channel</asp:LinkButton></td>
     
                            </tr>
     
                        </table>
     
                    </td>
                </tr>
                <tr style="height:500px">
                    <td style="vertical-align:top">
                        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                        </asp:ContentPlaceHolder>
                    </td>
                </tr>
                <tr>
                    <td class="Footer">Copyright  2013-2014 by Video Arts Company</td>
                </tr>
            </table>
        </form>
    </body>
    </html>
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top