The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Nov 10, 2009 at 10:14 AM
Edited Nov 10, 2009 at 10:22 AM

I have added the upload control to one of my web forms which is connected to a Master Page.

When i add the file upload to a simple web form it is working fine. But when i added this to a file which got master page i am getting error like this...

 

 

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

 

 

 

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +2108047
   com.flajaxian.FileUploader.Page_PreRenderComplete(Object sender, EventArgs e) +718
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +2063008
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2247
How should i add this control to avoid this error??...Please help me its urgent...
My aspx page has code like this

 

 

<%@ Page Title="" Language="C#" MasterPageFile="~/Common/MasterPage.master" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>

<%@ Register Assembly="com.flajaxian.FileUploader" Namespace="com.flajaxian" TagPrefix="fjx" %>




<asp:Content ID="Content1" ContentPlaceHolderID="MasterContent" runat="Server">
<fjx:FileUploader ID="FileUploader1" runat="server"></fjx:FileUploader>



</asp:Content>

Coordinator
Nov 11, 2009 at 10:19 AM

Remove the <%= ... %> statement that you use somewhere on the page or master page or wrap it inside a server side PlaceHolder

Nov 11, 2009 at 4:21 PM

I commented all the <%= ... %> statements,but still i am getting the same error. What more can be the reason???

Coordinator
Nov 11, 2009 at 6:05 PM

If this is what yo call comment <!-- --> that doesn't count as a server side comment. This is server side comment <%-- --%>

Instead of commenting I would suggest to put FileUploader in a PlaceHolder with runat="server"

Nov 12, 2009 at 8:07 AM
Edited Nov 12, 2009 at 8:09 AM

 

Thanks a lot. Its working now. Actually i commented some code before using '//'. Now after removing those its working fine. Thanks a lot. Great control. This has reduced my work by almost 20-24 hrs...

<input id="gwProxy" type="hidden" /><input id="jsProxy" onclick="jsCall();" type="hidden" />

Nov 26, 2009 at 5:31 PM

Hi vladb,

I put FileUploader in a PlaceHolder with runat="server" like this:

                        <asp:PlaceHolder ID="PlaceHolder1" runat="server">
                            <fjx:FileUploader ID="FJX_FileUploader" UseInsideUpdatePanel="true" runat="server"
                                JsFunc_FileStateChanged="FileStateChanged" MaxFileSize="10mb" MaxFileSizeReachedMessage="很抱歉,單一檔案大小不能大於{0}。"
                                MaxFileQueueSize="100MB" MaxFileQueueSizeReachedMessage="很抱歉,總上傳檔案的大小不能超過{0}。"
                                MaxNumberFiles="10" MaxFileNumberReachedMessage="很抱歉,一次最多只能同時上傳{0}個檔案,多餘的將會自動忽略。"
                                IsDebug="true">
                                <Adapters>
                                    <fjx:FileSaverAdapter />
                                </Adapters>
                            </fjx:FileUploader>
                        </asp:PlaceHolder>

,but still i am getting the same error.

Did I do something wrong?

 

 

Nov 27, 2009 at 11:49 PM

I am having the same issues and tried the above...  I am using a masterpage and I get the same error as above
:(