Hello everyone
Hopefully I am being stupid but I have the following problem with the rad file explorer. I've set it so a user can upload and delete files. If Istart with a blank cancas, i.e. nothing present in any existing folders and add/delete files, absolutely no problem at all (see Working.gif)
However, if I already have an existing file present in my file path, I experience a bit of nasty stuff (see NotWorking.gif) - as you can see, the file appears to be present, it isn't, it has been removed from the filepath as requested hence you see the 'resource not found' error when I attempt to open it.
Here is the code I have.
Markup
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
telerik:RadStyleSheetManager
ID
=
"RadStyleSheetManager1"
runat
=
"server"
/>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
script
type
=
"text/javascript"
>
(function (global, undefined) {
function OnClientFileOpen(oExplorer, args) {
var item = args.get_item();
var fileExtension = item.get_extension();
var fileDownloadMode = true;
if ((fileDownloadMode == true) && (fileExtension == "txt" || fileExtension == "xls" || fileExtension == "xlsx")) {// Download the file
// File is a image document, do not open a new window
args.set_cancel(true);
// Tell browser to open file directly
var requestImage = "Handler.ashx?path=" + item.get_url();
document.location = requestImage;
}
}
global.OnClientFileOpen = OnClientFileOpen;
})(window);
</
script
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"Configuratorpanel1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadFileExplorer1"
LoadingPanelID
=
"theLoadingPanel"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
div
>
<
telerik:RadFileExplorer
runat
=
"server"
ID
=
"RadFileExplorer1"
Width
=
"595px"
Height
=
"320px"
OnClientFileOpen
=
"OnClientFileOpen"
EnableOpenFile
=
"true"
>
<
Configuration
MaxUploadFileSize
=
"51200000"
></
Configuration
>
</
telerik:RadFileExplorer
>
</
div
>
</
form
>
</
body
>
</
html
>
C#
using
System;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
System.Configuration;
using
System.Web.Security;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
Telerik.Web.UI;
public
partial
class
Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
//set properties according to configuration panel
RadFileExplorer1.Configuration.SearchPatterns =
new
string
[] {
"*.jpg"
,
"*.jpeg"
,
"*.gif"
,
"*.png"
,
"*.txt"
,
"*.xls"
,
"*.xlsx"
};
RadFileExplorer1.VisibleControls = GetVisibleControls();
//Set initial folder to open. Note that the path is case sensitive!
//var filePath = "~/TestData";
var filePath =
"~/TestData/6645dc9a-5e8c-46e9-aad0-ba9b087aae4a"
;
//var filePath = "~/TestData/a4089fd8-3170-4956-a8f5-1ea21a19d984";
RadFileExplorer1.Configuration.UploadPaths =
new
string
[] { filePath };
RadFileExplorer1.Configuration.ViewPaths =
new
string
[] { filePath };
RadFileExplorer1.Configuration.DeletePaths =
new
string
[] { filePath };
if
(!IsPostBack)
{
//Set initial folder to open. Note that the path is case sensitive!
RadFileExplorer1.InitialPath = Page.ResolveUrl(filePath);
}
}
protected
Telerik.Web.UI.FileExplorer.FileExplorerControls GetVisibleControls()
{
Telerik.Web.UI.FileExplorer.FileExplorerControls explorerControls = 0;
explorerControls |= Telerik.Web.UI.FileExplorer.FileExplorerControls.All;
return
explorerControls;
}
}
If anyone can point out what I am doing wrong or what else I may need to implement, I'd be most grateful.
Rich