Wednesday 11 June 2014

Show an Alert Message if no file was uploaded in RadfileExplorer Upload Popup

We may have scenario like to validate if no file was uploaded in Rad upload of rad file explorer
For this first write an javascript function like this in design page:
function OnClientLoad(explorer, args) {
//Find upload button and attach an event handler
                var uploadButton = $find("<%=RadFileExplorer1.ClientID%>" +"_btnUpload");
                uploadButton.add_clicked(function()
                {
                    var upload = $find('<%=RadFileExplorer1.Upload.ClientID %>');
                    var inputs = upload.getFileInputs();
                    var count = 0;
                    for (var i = 0 ; i < inputs.length; i++) {
                        if (inputs[i].value.length != 0) {
                            count++;
                        }
                    }
                    if(count == 0)
                        alert('Please select one file to upload.');
                })
            }
And add this function in RadfileExplorer client load event like

<telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" OnClientLoad="OnClientLoad"  </telerik:RadFileExplorer>

No comments:

Post a Comment