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=14.0.0.0, 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=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, 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">
.submitArea
{
padding-top: 20px;
padding-bottom: 20px;
}
</style>
<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]);
}
</script>
<telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
<telerik:RadProgressManager ID="Radprogressmanager1" runat="server"></telerik:RadProgressManager>
<table>
<tr>
<td>
<telerik:RadUpload ID="RadUpload1" runat="server"></telerik:RadUpload>
</td>
<td>
<div>
<asp:Repeater ID="repeaterResults" runat="server" Visible="False">
<HeaderTemplate>
<div class="title">File caricati:</div>
<br />
</HeaderTemplate>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "FileName")%>
<br />
<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>
<br />
<br />
</ItemTemplate>
</asp:Repeater>
<asp:Label ID="labelNoResults" runat="server" Visible="True">Nessun file caricato</asp:Label>
</div>
</td>
</tr>
</table>
<div class="submitArea">
<asp:Button ID="SubmitButton" runat="server" Text="Upload files" OnClick="SubmitButton_Click"></asp:Button>
</div>
<telerik:RadProgressArea ID="ProgressArea1" EnableAjaxSkinRendering="false" runat="server">
</telerik:RadProgressArea>
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)
{
base.OnInit(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;
repeaterResults.DataBind();
labelNoResults.Visible = false;
repeaterResults.Visible = true;
}
else
{
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
my .aspx:
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, 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=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, 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">
.submitArea
{
padding-top: 20px;
padding-bottom: 20px;
}
</style>
<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]);
}
</script>
<telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
<telerik:RadProgressManager ID="Radprogressmanager1" runat="server"></telerik:RadProgressManager>
<table>
<tr>
<td>
<telerik:RadUpload ID="RadUpload1" runat="server"></telerik:RadUpload>
</td>
<td>
<div>
<asp:Repeater ID="repeaterResults" runat="server" Visible="False">
<HeaderTemplate>
<div class="title">File caricati:</div>
<br />
</HeaderTemplate>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "FileName")%>
<br />
<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>
<br />
<br />
</ItemTemplate>
</asp:Repeater>
<asp:Label ID="labelNoResults" runat="server" Visible="True">Nessun file caricato</asp:Label>
</div>
</td>
</tr>
</table>
<div class="submitArea">
<asp:Button ID="SubmitButton" runat="server" Text="Upload files" OnClick="SubmitButton_Click"></asp:Button>
</div>
<telerik:RadProgressArea ID="ProgressArea1" EnableAjaxSkinRendering="false" runat="server">
</telerik:RadProgressArea>
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)
{
base.OnInit(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;
repeaterResults.DataBind();
labelNoResults.Visible = false;
repeaterResults.Visible = true;
}
else
{
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