1

我正在尝试使用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>
4

1 回答 1

0

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

setTimeout(function () { $(questionNode).find('> .answer > div > .MultiFile-wrap > .multi').removeAttr('disabled');}, 200);
于 2012-12-17T19:24:31.887 回答