webpart with radupload

2 posts, 0 answers
  1. Carla
    Carla avatar
    7 posts
    Member since:
    Apr 2014

    Posted 10 Apr 2014 Link to this post

    Hi everyone...i've created a webpart containing a a mask for file uploads, i've not used RadAsyncUpload because RadUpload is more suitable for my purpose....that's my code:

    my .aspx:

    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Assembly Name="Telerik.Web.UI, Version=2014.1.225.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI, Version=2014.1.225.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FileUploadWebPartUserControl.ascx.cs" Inherits="FileUpload.FileUploadWebPart.FileUploadWebPartUserControl" %>

    <style type="text/css">

         padding-top: 20px;
         padding-bottom: 20px;

    <script type="text/javascript">

        function pageLoad() { }

        var prm = Sys.WebForms.PageRequestManager.getInstance();
        var originalClientSubmit;

        if (!originalClientSubmit)
            originalClientSubmit = Telerik.Web.UI.RadProgressManager.prototype._clientSubmitHandler;

        Telerik.Web.UI.RadProgressManager.prototype._clientSubmitHandler = function (e) {
            if (!prm._postBackSettings.async)
                originalClientSubmit.apply(this, [e]);

    <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
    <telerik:RadProgressManager ID="Radprogressmanager1" runat="server"></telerik:RadProgressManager>
                <telerik:RadUpload ID="RadUpload1" runat="server"></telerik:RadUpload>
                    <asp:Repeater ID="repeaterResults" runat="server" Visible="False">
                            <div class="title">File caricati:</div>           
                            <br />
                            <%#DataBinder.Eval(Container.DataItem, "FileName")%> 
                            <br />
                            <%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>
                            <br />
                            <br />
                    <asp:Label ID="labelNoResults" runat="server" Visible="True">Nessun file caricato</asp:Label>
    <div class="submitArea">
        <asp:Button ID="SubmitButton" runat="server" Text="Upload files" OnClick="SubmitButton_Click"></asp:Button>
    <telerik:RadProgressArea ID="ProgressArea1" EnableAjaxSkinRendering="false" runat="server">

    my .aspx.cs:

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Telerik.Web.UI;

    namespace FileUpload.FileUploadWebPart
        public partial class FileUploadWebPartUserControl : UserControl

            protected override void OnInit(EventArgs e)
                ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
                if (scriptManager == null)
                    scriptManager = new RadScriptManager();
                    this.Page.Form.Controls.AddAt(0, scriptManager);

            protected override void OnLoad(EventArgs e)
                string[] allowedFileExtensions = new string[3] { ".xls", ".xlsx", ".xml" };
                RadUpload1.AllowedFileExtensions = allowedFileExtensions;
                RadUpload1.MaxFileInputsCount = 3 - RadUpload1.UploadedFiles.Count;
                RadUpload1.InitialFileInputsCount = 3 - RadUpload1.UploadedFiles.Count;
            protected void SubmitButton_Click(object sender, EventArgs e)
                if (RadUpload1.UploadedFiles.Count > 0)
                    repeaterResults.DataSource = RadUpload1.UploadedFiles;
                    labelNoResults.Visible = false;
                    repeaterResults.Visible = true;
                    labelNoResults.Visible = true;
                    repeaterResults.Visible = false;


    I've two little problems i want to ask for help:

    1 - on the SubmitButton_Click (Upload Files), i receive a message error that you can see in file attached "Immagine 1"; the file is correctly uploaded as i can see in debug (RadUpload1.UploadedFiles contains the element i've uploaded) but i don't want to see anymore this message error; i've just watched following posts about this matter: http://www.telerik.com/forums/277270-radupload-ajax-callback-error-source-url-returned-invalid-content - http://www.telerik.com/forums/radupload-ajax-callback-erro-source-url-returned-invalid-content but neither help me to solve the problem.

    2 - the "Remove" button is not styled correctly as you can see in file attached "Immagine 2", how can i modify its style?

    Thanks in advance,

    Regards, Carla
  2. Plamen
    Plamen avatar
    2812 posts

    Posted 11 Apr 2014 Link to this post

    Hi Carla,

    Straight to the points:
    1) You can refer to this help topic Ajax Callback Error When Uploading Files where a solution of the described error is provided.
    2)The CSS class selector of the remove button is ".ruRemove" as described in this CSS Skin File Selectors help topic so you can apply with it the desired style.

    Hope this will be helpful.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top