This is a migrated thread and some comments may be shown as answers.

Adding RadUpload through code behind

3 Answers 149 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Colan
Top achievements
Rank 1
Colan asked on 04 Nov 2010, 02:33 PM
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;
                radCodeBlock.Controls.Add(radUpload);
                oControl.Controls.Add(radCodeBlock);

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 05 Nov 2010, 05:32 PM
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");
        </script>
    </telerik:RadCodeBlock>
 

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
0
Mike
Top achievements
Rank 1
answered on 09 Feb 2011, 06:20 PM
If I'd like to create a RadCodeBlock in my codebehind, how do I specify the javascript that it will contain?

Mike
0
Genady Sergeev
Telerik team
answered on 15 Feb 2011, 10:50 AM
Hi Colan,

You could use the following code:

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


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.
Tags
Upload (Obsolete)
Asked by
Colan
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Mike
Top achievements
Rank 1
Share this question
or