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

fileexplorer validation

2 Answers 36 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Ronen
Top achievements
Rank 1
Ronen asked on 08 Aug 2010, 11:43 AM
How do i validate upon submitting a form that the user actually selected a file in the file explorer?

2 Answers, 1 is accepted

Sort by
0
Accepted
Fiko
Telerik team
answered on 12 Aug 2010, 08:04 AM
Hello Ronen,

Selecting a file in RadFileExplorer does not cause postback to the server. In your case you need to implement your custom logic using the OnClientItemSelected event of the control. This event is fired when an item is selected.

All the best,
Fiko
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
Ronen
Top achievements
Rank 1
answered on 12 Aug 2010, 08:59 AM

i already used another text box that shows the path of the file, and i used a validator to check if it's empty or doesn't contain a file:


 

 

 

function validateFile(source, args) {

 

 

 

var regex = /.*\..{3,4}/;

 

 

 

 

 

 

var textBoxFileName = document.getElementById('<%=TextBoxFileName.ClientID%>');

 

 

 

if (textBoxExistingFile != null && textBoxFileName != null)

 

{

 

 

if (textBoxFileName.value.length == 0 ||

 

textBoxFileName.value.search(regex) == -1)

{

args.IsValid =

 

false;

 

 

 

return;

 

}

}

args.isValid =

 

true;

 

}


 

 

function fillFileName(sender, args) {

 

 

var label = document.getElementById('<%=TextBoxFileName.ClientID%>');

 

 

if (label != null)

 

label.innerText = args.get_item().get_path();

OnClientItemSelected(sender, args);

}




 

<telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" Configuration-MaxUploadFileSize="307200"

 

 

EnableCreateNewFolder="false" EnableOpenFile="true" OnClientItemSelected="fillFileName">

 

 

<Configuration SearchPatterns="*.jpg,*.jpeg,*.JPG,*.JPEG,*.gif,*.GIF,*.png,*.PNG" />

 

 

</telerik:RadFileExplorer>

 

Tags
FileExplorer
Asked by
Ronen
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Ronen
Top achievements
Rank 1
Share this question
or