Home > Net >  Can I customize ajax file upload in asp.net(vb)?
Can I customize ajax file upload in asp.net(vb)?

Time:12-17

I am uploading my pdf file by using ajax file upload and I'm using vs 2019 (asp.net,vb). I want to change the display of ajax upload format.<< example: Drop File here → Drop PDF File.>>

Here is my asp source.

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">    
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">        
    
   
    <div style="width:40%;padding:25px">
        <asp:ScriptManager runat="server"></asp:ScriptManager>
        <ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" 
            OnClientUploadCompleteAll="MyCompleteAll"  ChunkSize="16384" AllowedFileTypes="pdf" MaximumNumberOfFiles="10" />
            <asp:Button ID="cmdDone" runat="server" Text="Done" style="display:none" ClientIDMode="Static" />
            <script>                

                function MyCompleteAll() {
                    $('cmdDone').click()
                }
                
            </script>
    </div>
</asp:Content>

I used some scripts which one I founded on net but it didn't work.

 <script type="text/javascript">   

        $(document).ready(function () {
            document.getElementsByClassName
            $(".ajax__fileupload_dropzone").text("Drop PDF File.");

            document.getElementsByClassName
            $(".ajax__fileupload_uploadbutton").text("UploadNow");

        });

</script>

I hope someone would help me for this. Thanks ^^

CodePudding user response:

You can change it this way:

        <script>

        $(document).ready(function () {
            Sys.Extended.UI.Resources.AjaxFileUpload_DropFiles = "Drop PDF here";
            AjaxFileUpload_change_text();
             });

        </script>

The list of text changes can be done with these settings:

function AjaxFileUpload_change_text() {
     Sys.Extended.UI.Resources.AjaxFileUpload_SelectFile = "Select File";
     Sys.Extended.UI.Resources.AjaxFileUpload_DropFiles = "Drop files here";
     Sys.Extended.UI.Resources.AjaxFileUpload_Pending = "pending";
     Sys.Extended.UI.Resources.AjaxFileUpload_Remove = "Remove";
     Sys.Extended.UI.Resources.AjaxFileUpload_Upload = "Upload";
     Sys.Extended.UI.Resources.AjaxFileUpload_Uploaded = "Uploaded";
     Sys.Extended.UI.Resources.AjaxFileUpload_UploadedPercentage = "uploaded {0} %";
     Sys.Extended.UI.Resources.AjaxFileUpload_Uploading = "Uploading";
     Sys.Extended.UI.Resources.AjaxFileUpload_FileInQueue = "{0} file(s) in queue.";
     Sys.Extended.UI.Resources.AjaxFileUpload_AllFilesUploaded = "All Files Uploaded.";
     Sys.Extended.UI.Resources.AjaxFileUpload_FileList = "List of Uploaded files:";
     Sys.Extended.UI.Resources.AjaxFileUpload_SelectFileToUpload = "Please select file(s) to upload.";
     Sys.Extended.UI.Resources.AjaxFileUpload_Cancelling = "Cancelling...";
     Sys.Extended.UI.Resources.AjaxFileUpload_UploadError = "An Error occured during file upload.";
     Sys.Extended.UI.Resources.AjaxFileUpload_CancellingUpload = "Cancelling upload...";
     Sys.Extended.UI.Resources.AjaxFileUpload_UploadingInputFile = "Uploading file: {0}.";
     Sys.Extended.UI.Resources.AjaxFileUpload_Cancel = "Cancel";
     Sys.Extended.UI.Resources.AjaxFileUpload_Canceled = "cancelled";
     Sys.Extended.UI.Resources.AjaxFileUpload_UploadCanceled = "File upload cancelled";
     Sys.Extended.UI.Resources.AjaxFileUpload_DefaultError = "File upload error";
     Sys.Extended.UI.Resources.AjaxFileUpload_UploadingHtml5File = "Uploading file: {0} of size {1} bytes.";
     Sys.Extended.UI.Resources.AjaxFileUpload_error = "error";
 }
  • Related