【问题标题】:jQuery MultFile upload disables the upload buttonjQuery多文件上传禁用上传按钮
【发布时间】:2012-11-12 16:05:19
【问题描述】:

我正在尝试使用jQuery Multiple File Upload,但在验证时遇到问题。验证运行后,文件上传控件被禁用,我不知道为什么。我在这里重新创建了最低限度来演示这个问题。

<%@ Page Language="C#" AutoEventWireup="true"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<script language="c#" runat="server">
    protected void validate(object source, ServerValidateEventArgs args)
    {
        args.IsValid = false;
    }
</script>
<head runat="server">
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery.MultiFile.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        function validate(sender, args)
        {
            args.IsValid = false;
            //addedd as suggested on the following, but it doesn't work
            //fyneworks.com/jquery/multiple-file-upload/#tab-Uploading
            $.fn.MultiFile.reEnableEmpty();  
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:FileUpload ID="attachments" runat="server" class="multi"  />
        <asp:CustomValidator runat="server" ID="customValidator" 
                             ErrorMessage="This field is required" 
                             OnServerValidate="validate"
                             ClientValidationFunction="validate" />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Submit" />
    </form>
</body>
</html>

【问题讨论】:

  • 我也遇到同样的问题你能解决吗?
  • 我以一种非常糟糕的方式解决了它,只是手动重新启用它。 setTimeout(function () { $(questionNode).find('> .answer > div > .MultiFile-wrap > .multi').removeAttr('disabled');}, 200);

标签: jquery asp.net


【解决方案1】:

我想出解决此问题的唯一方法是手动重新启用该按钮。 我添加了超时只是为了确保在我的代码运行之前一切都已完成。

setTimeout(function () { $(questionNode).find('> .answer > div > .MultiFile-wrap > .multi').removeAttr('disabled');}, 200);

【讨论】:

    猜你喜欢
    • 2012-03-23
    • 2016-09-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 1970-01-01
    • 1970-01-01
    • 2012-05-24
    • 1970-01-01
    相关资源
    最近更新 更多