I am attempting to use jQuery Multiple File Upload, but having problems with validation. The file upload control gets disabled after my validation runs, and I can’t figure out why. I recreated the bare minimum here to demonstrate the problem.
<%@ 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>
The only way I figured out how to solve this was to re-enable the button manually.
I added the timeout just to make sure everything was done executing before my code ran.