我可以在 asp.net(vb) 中自定义 ajax 文件上传吗?

Posted

技术标签:

【中文标题】我可以在 asp.net(vb) 中自定义 ajax 文件上传吗?【英文标题】:Can I customize ajax file upload in asp.net(vb)? 【发布时间】:2022-01-20 02:45:22 【问题描述】:

我正在使用 ajax 文件上传来上传我的 pdf 文件,并且我正在使用 vs 2019 (asp.net,vb)。 我想更改ajax上传格式的显示。>

这是我的asp源代码。

<%@ 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>

我使用了一些我在网上创建的脚本,但它不起作用。

 <script type="text/javascript">   

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

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

        );

</script>

我希望有人能帮助我。谢谢^^

【问题讨论】:

【参考方案1】:

你可以这样改变它:

        <script>

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

        </script>

文本更改列表可以通过以下设置完成:

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";
 

【讨论】:

谢谢你。你能告诉我在哪里可以添加吗?我是这样添加的,但是没有用。 ' ' 放入被脚本标签包围的第一个代码示例 - 就在您的标记中 - 比如说在 ajaxfile 上传控件之后。 谢谢你。我在脚本中编写函数并在页面加载时调用该脚本,它确实有效。

以上是关于我可以在 asp.net(vb) 中自定义 ajax 文件上传吗?的主要内容,如果未能解决你的问题,请参考以下文章

在 ASP.NET WebApi 2 中自定义承载令牌 JSON 结果

如何在 ASP NET MVC 中自定义不显眼的验证 JQuery 消息?

如何在 asp.net web api 2 中自定义对我自己的一组表的身份验证?

ASP.Net MVC 2 中自定义成员资格提供程序中的角色分组

asp.net中在Gridview中自定义一列操作,应该怎么做?

ASP.NET WEB API 中自定义对象的序列化 [重复]