Error Message on file extension

Thread is closed for posting
2 posts, 0 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 22 Nov 2011 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Nov 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top