This is a migrated thread and some comments may be shown as answers.

Radupload + custom validator + call out extender

2 Answers 148 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
josephjijo
Top achievements
Rank 1
josephjijo asked on 21 May 2010, 11:53 AM
Hi,
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> 

2 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 26 May 2010, 03:06 PM
Hello josephjijo,

This seems to be problem with the ValidatorCallout control, not with RadUpload. I have tried to use it with custom validator, however, no avail. JavaScript error is thrown. I suggest that you use only the Custom Validator for this scenario.

All the best,
Genady Sergeev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jeremy
Top achievements
Rank 1
answered on 02 Jul 2010, 02:49 AM
Hi

To use the AJAX Control Toolkit ValidatorCalloutExtender you MUST provide a ControlToValidate. Of course to use the custom validator for a radupload you don't provide a ControlToValidate :)
I got around this by using a dummy control and it works, but the callout extender appears BEHIND the RadWindow. Any solution to this?

<telerik:RadWindow ID="rwImport" runat="server" Behaviors="None" AutoSize="true" Modal="true" VisibleStatusbar="False" Title="Upload Something"
    <ContentTemplate>                
        <div id="divupload" style="height:140px; padding:10px;">  
            <telerik:RadUpload ID="RadUpload1" runat="server" AllowedFileExtensions=".imp" ControlObjectsVisibility="None"
            </telerik:RadUpload>         
            <asp:TextBox ID="dummy" runat="server" Width="0" Text="x" Height="0" BackColor="White" BorderStyle="None"
            </asp:TextBox> 
            <asp:customvalidator runat="server" id="cvUpload" display="None" clientvalidationfunction="ValidateFileExtension" ErrorMessage="Invalid file selected. Please select a file with extension '.imp'." ControlToValidate="dummy"
            </asp:customvalidator>  
            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="cvUpload"
            </asp:ValidatorCalloutExtender> 
            <br /> 
            <asp:Button ID="btnImport" runat="server" CssClass="formbutton" Text="Import" onclick="btnImport_Click" /> 
            <input type="button" class="formbutton" onclick="$find('<%= rwImport.ClientID %>').close();" value="Cancel" /> 
        </div> 
    </ContentTemplate>     
</telerik:RadWindow> 
 
<script type="text/javascript"
    function ValidateFileExtension(sender, args) { 
        args.IsValid = getRadUpload('<%= rwImport.ContentContainer.FindControl("RadUpload1").ClientID %>').validateExtensions(); 
    }  
</script> 
Tags
Upload (Obsolete)
Asked by
josephjijo
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Jeremy
Top achievements
Rank 1
Share this question
or