File validation does not work for me!

2 posts, 0 answers
  1. elaheh
    elaheh avatar
    7 posts
    Member since:
    Oct 2010

    Posted 03 Jul 2012 Link to this post

    I have tried to use the codes are for validation in Asyncupload and uplod tools in these links:

    But none of them works correcrtly! when I select a non-valid file (for example a pdf file which its extension is changed to jpg), it does not prevent uploading it.

    this is all my code with Asyncupload:
    <asp:Content ID="Content2" ContentPlaceHolderID="content2" Runat="Server">
    <script type="text/javascript">
            function validationFailed(sender, eventArgs) {
                $(".ErrorHolder").append("<p>Validation failed for '" + eventArgs.get_fileName() + "'.</p>").fadeIn("slow");
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                <asp:ScriptReference Assembly="Telerik.Web.UI"
    <telerik:RadButton ID="uploadbtn" runat="server" Text="upload"
        <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server"
            TargetFolder="~/upload" OnClientValidationFailed="validationFailed"
            onfileuploaded="RadAsyncUpload1_FileUploaded" >
            <telerik:FileFilter Description="Images(jpeg;jpg)" Extensions="jpeg,jpg" />

    and in code behind for upload button:
    protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
            Label fileName = new Label();
            fileName.Text = e.File.FileName;
            if (e.IsValid)
                Response.Write(fileName + "::true");
     Is there anything missing from me?
  2. Plamen
    Plamen avatar
    2723 posts

    Posted 04 Jul 2012 Link to this post

    Hi Elaheh,

    The validation is checking exactly the extension so if it is changed the expected behavior will be the file to be uploaded.

    Hope this will explain the issue.

    All the best,
    Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top