Hi,
I have tried to use the codes are for validation in Asyncupload and uplod tools in these links:
http://demos.telerik.com/aspnet-ajax/upload/examples/async/validation/defaultcs.aspx?product=asyncupload
http://www.telerik.com/help/aspnet-ajax/upload-client-side-validation.html
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:
and in code behind for upload button:
Is there anything missing from me?
I have tried to use the codes are for validation in Asyncupload and uplod tools in these links:
http://demos.telerik.com/aspnet-ajax/upload/examples/async/validation/defaultcs.aspx?product=asyncupload
http://www.telerik.com/help/aspnet-ajax/upload-client-side-validation.html
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"> //<![CDATA[ function validationFailed(sender, eventArgs) { $(".ErrorHolder").append("<p>Validation failed for '" + eventArgs.get_fileName() + "'.</p>").fadeIn("slow"); } //]]> </script><telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server"> </telerik:RadStyleSheetManager> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js"> </asp:ScriptReference> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js"> </asp:ScriptReference> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js"> </asp:ScriptReference> </Scripts> </telerik:RadScriptManager><telerik:RadButton ID="uploadbtn" runat="server" Text="upload" onclick="uploadbtn_Click"> </telerik:RadButton> <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" AllowedFileExtensions="jpg,jpeg" TargetFolder="~/upload" OnClientValidationFailed="validationFailed" onfileuploaded="RadAsyncUpload1_FileUploaded" > <FileFilters> <telerik:FileFilter Description="Images(jpeg;jpg)" Extensions="jpeg,jpg" /> </FileFilters> </telerik:RadAsyncUpload>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"); } else { Response.Write("false"); } }