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

Error Message on file extension

1 Answer 138 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 22 Nov 2011, 11:14 PM
I have an uploader with accepted file types set. Is there a way to display an error message? Right now, it just doesn't upload the file but no message is displayed?

<telerik:RadUpload ID="attachedFile" runat="server" MaxFileInputsCount="1" ControlObjectsVisibility="None"
                Width="300" TargetFolder="~/UploadedGrantResponse" OverwriteExistingFiles="true" AllowedFileExtensions=".doc,.docx,.pdf">
                </telerik:RadUpload>


If (attachedFile.UploadedFiles.Count > 0) Then
 
    For Each postedFile As UploadedFile In attachedFile.UploadedFiles
        If Not [Object].Equals(postedFile, Nothing) Then
            targetFileName = Path.Combine(targetFolder, postedFile.GetNameWithoutExtension() & " " & time & postedFile.GetExtension())
            fileName = postedFile.GetNameWithoutExtension() & "%20" & time & postedFile.GetExtension()
            fileName = fileName.replace(" ", "%20")
            deleteFile = postedFile.GetName()
            postedFile.SaveAs(targetFileName)
        End If 'if not object
 
    Next 'for each uploaded file
 
End If 'if attachedFile.UploadedFiles.Count

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Nov 2011, 06:36 AM
Hello,

You can try the following.
ASPX:
<telerik:RadUpload ID="RadUpload1" runat="server" InitialFileInputsCount="1" AllowedFileExtensions=".zip,.jpg,.jpeg" />
<asp:Button ID="buttonSubmit" runat="server" Text="Submit" Style="margin-top: 6px" />
<asp:CustomValidator ID="Customvalidator1" runat="server" Display="Dynamic" ClientValidationFunction="validateRadUpload1">
</asp:CustomValidator>
JS:
<script type="text/javascript">
   function validateRadUpload1(source, arguments)
  {
    arguments.IsValid = $find('<%= RadUpload1.ClientID %>').validateExtensions();
    alert("Invalid Extension");
  }
</script>

Thanks,
Princy.
Tags
Upload (Obsolete)
Asked by
Web Services
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or