Hi,
I want to request at least one file for upload .
but when i use a call out extender, its not working.
I want to request at least one file for upload .
but when i use a call out extender, its not working.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<!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"> |
<head runat="server"> |
<title></title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<div> |
<asp:ScriptManager ID="ScriptManager1" runat="server"> |
</asp:ScriptManager> |
<telerik:RadUpload ID="RadUpload1" InitialFileInputsCount="1" AllowedFileExtensions=".txt" |
TargetFolder="~/uploads" runat="server" ControlObjectsVisibility="None"> |
</telerik:RadUpload> |
<asp:CustomValidator ID="CustomValidator1" runat="server" Display="None" ErrorMessage="Error" |
ValidationGroup="MyFile" ClientValidationFunction="validateRadUpload" /> |
<cc1:ValidatorCalloutExtender ID="VCE_CustomValidator1" runat="server" TargetControlID="CustomValidator1"> |
</cc1:ValidatorCalloutExtender> |
</div> |
<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="MyFile" /> |
</form> |
<script type="text/javascript"> |
function validateRadUpload(source, e) { |
e.IsValid = false; |
var upload = $find("<%= RadUpload1.ClientID %>"); |
var inputs = upload.getFileInputs(); |
for (var i = 0; i < inputs.length; i++) { |
//check for empty string or invalid extension |
if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) { |
e.IsValid = true; |
break; |
} |
else { |
e.IsValid = false; |
} |
} |
} |
</script> |
</body> |
</html> |