Adding RadUpload through code behind

Thread is closed for posting
4 posts, 0 answers
  1. Colan
    Colan avatar
    7 posts
    Member since:
    Dec 2007

    Posted 04 Nov 2010 Link to this post

    Tried to add radupload control to the page programmatically, the result was an error "... Controls collections cannot be modified because the control contains code blocks..."  Further down in the yellow screen of death was a suggestion that adding a RadCodeBlock may resolve the issue. So... added a RadCodeBlock, added the upload control to the codeblock and add the codeblock to the page.

    Same error.

    A snippet of the code:

                    var radCodeBlock = new RadCodeBlock();
                    radCodeBlock.ID = "Block1";
                    var radUpload = new RadUpload();
                    radUpload.ID = "upload_" + szDbColumn;
                    radUpload.MaxFileInputsCount = 1;
                    radUpload.ControlObjectsVisibility = ControlObjectsVisibility.None;
  2. Genady Sergeev
    Genady Sergeev avatar
    1596 posts

    Posted 05 Nov 2010 Link to this post

    Hi Colan,

    RadUpload should not be added to RadCodeBlock itself. Instead, add the JavaScript where RadUpload is accessed inside RadCodeBlock. For example, you have something like the following:

    var upload = $find("<%= RadUpload1.ClientID %>");

    It should be place inside RadCodeBlock, like this:

    <telerik:RadCodeBlock runat="server" ID="RadCodeBlock">
            <script type="text/javascript">
                var upload = $find("RadAsyncUpload1");

    All the best,
    Genady Sergeev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mike
    Mike avatar
    20 posts
    Member since:
    Jan 2011

    Posted 09 Feb 2011 Link to this post

    If I'd like to create a RadCodeBlock in my codebehind, how do I specify the javascript that it will contain?

  5. Genady Sergeev
    Genady Sergeev avatar
    1596 posts

    Posted 15 Feb 2011 Link to this post

    Hi Colan,

    You could use the following code:

    var codeBlock = new RadCodeBlock();
    codeBlock.Controls.Add(new Literal() { Text = "your script goes here" });

    All the best,
    Genady Sergeev
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top