I'm having trouble getting client side validation of file extensions to work. I have a page where users can upload a single file using the RadUpload control. I'm trying to use the validateExtensions function to validate the file extension. I believe my code matches the example in your documentation but I am getting the javascript error "'null' is null or not an object" whenever validateExtensions is called. If I hardcode true or false in place of my call to validateExtensions then I don't get the javascript error. Below is my code.
| <%@ Page Language="VB" MasterPageFile="~/HBC_MP.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="data_transfer_upload_Default" title="File Transfer Admin Detail" Theme="MainTheme" %> |
| <%@ Register Assembly="RJS.Web.WebControl.PopCalendar" Namespace="RJS.Web.WebControl" TagPrefix="rjs" %> |
| <%@ Register TagPrefix="rad" Namespace="Telerik.WebControls" Assembly="RadUpload.Net2" %> |
| <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> |
| <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> |
| <div id="container_middle" class="clearfix" style="background-color:#eeeeee"> |
| <div id="content" style="width:910px"> |
| <table style="width:100%"> |
| <tr> |
| <td> |
| <h1 class="brand" style="width:600px;BACKGROUND-color: #eee;BORDER-LEFT: 0px;BORDER-RIGHT: 0px;text-transform:none;float:left;"> |
| Data Transfer - File Upload |
| </h1> |
| </td> |
| <td style="vertical-align:middle;text-align:right"> |
| <asp:HyperLink ID="linkDownload" runat="server" NavigateUrl="~/data_transfer/Default.aspx" Font-Size="11.3px" Font-Underline="true">Download Files</asp:HyperLink> |
| </td> |
| </tr> |
| </table> |
| <asp:ScriptManager ID="ScriptManager1" runat="server"> |
| </asp:ScriptManager> |
| <br \> |
| <script type="text/javascript"> |
| function increasingFileInputWidth(radUpload, args) |
| { |
| //If the Checkboxes in RadUpload are not visible, change the index to 0 |
| var cell = args.Row.cells[0]; |
| var inputs = cell.getElementsByTagName('INPUT'); |
| for (var i=0; i<inputs.length; i++) |
| { |
| if (inputs[i].type == "file") |
| { |
| inputs[i].size = 75; |
| } |
| } |
| } |
| </script> |
| <table align="Center"> |
| <tr> |
| <td> |
| <table class="tablenav" align="left" border="0" cellpadding="0" cellspacing="0" style="margin-top:10px;margin-left:0px;margin-bottom:0px;width:750px;"> |
| <tr> |
| <td align="right" valign="middle"> |
| <rad:radprogressmanager id="Radprogressmanager1" runat="server" /> |
| </td> |
| <td valign="middle" colspan="3"> |
| <asp:Label ID="lblMsg" runat="server" ForeColor="Red"></asp:Label> |
| <asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Please Correct the Following"/> |
| </td> |
| </tr> |
| <tr style="height:23px"> |
| <td align="right" valign="middle" style="height: 23px"> |
| <asp:Label ID="lblCurrentFile" runat="server" Text="Currently Loaded File Name:"></asp:Label></td> |
| <td valign="middle" style="height: 23px" colspan="3"> |
| <asp:Label ID="lblCurrentFileData" runat="server" EnableTheming="False"></asp:Label></td> |
| </tr> |
| <tr style="height:23px"> |
| <td valign="middle" align="right" style="height: 23px"> |
| <asp:Label ID="lblFile" runat="server" Text="Choose File:"></asp:Label></td> |
| <td valign="middle" style="height: 23px;padding-left: 2px" colspan="3"> |
| Files can not be larger than 50MB |
| <rad:radupload |
| id="RadUpload1" |
| runat="server" MaxFileInputsCount="1" ControlObjectsVisibility="None" OnClientAdded="increasingFileInputWidth" EnableFileInputSkinning="False" Skin="Default" |
| AllowedFileExtensions=".doc,.ppt,.xls,.pdf,.jpg,.jpeg,.gif,.txt,.avi,.dxf,.tif,.tiff" /> |
| <rad:radprogressarea id="progressArea1" runat="server" ProgressIndicators="TotalProgressBar, TotalProgress, TotalProgressPercent, RequestSize, TimeElapsed, TimeEstimated, TransferSpeed" Skin="HBC"></rad:radprogressarea> |
| <asp:CustomValidator runat="server" id="CustomValidator1" |
| ClientValidationFunction="validateRadUpload1" |
| OnServerValidate="CustomValidator1_ServerValidate" ErrorMessage="Invalid File Extension." Display="None"></asp:CustomValidator> |
| <script type="text/javascript"> |
| function validateRadUpload1(source, arguments) |
| { |
| arguments.IsValid = $find("<%=RadUpload1.ClientID%>").validateExtensions(); |
| } |
| </script> |
| </td> |
| </tr> |
| <tr style="height:23px"> |
| <td align="right"> |
| <asp:Label ID="lblFileDesc" runat="server" Text="File Description:"></asp:Label> |
| </td> |
| <td colspan="3"> |
| <asp:TextBox ID="txtFileDesc" runat="server" Width="513px"></asp:TextBox> |
| <asp:RequiredFieldValidator ID="rfvFileDesc" runat="server" ControlToValidate="txtFileDesc" |
| ErrorMessage="File Description is Required." >*</asp:RequiredFieldValidator></td> |
| </tr> |
| </table> |
| <br /> |
| <asp:UpdatePanel ID="UpdatePanel1" runat="server"> |
| <ContentTemplate> |
| <table class="tablenav" align="left" border="0" cellpadding="0" cellspacing="0" style="margin-top:10px;margin-left:0px;margin-bottom:0px;width:750px;"> |
| <tr style="height:23px"> |
| <td align="right" style="width:110px"> |
| <asp:Label ID="lblCategory" runat="server" Text="Category:"></asp:Label> |
| </td> |
| <td style="width:215px"> |
| <asp:DropDownList ID="ddlCategory" runat="server"> |
| </asp:DropDownList> |
| <asp:Label ID="lblNoCategory" runat="server" Text="N/A" EnableTheming="False"></asp:Label> |
| </td> |
| <td align="left" > |
| <asp:Label ID="lblFileType" runat="server" Text="File Type:"></asp:Label> |
| </td> |
| <td> |
| <asp:DropDownList ID="ddlFileType" runat="server" AutoPostBack="True"> |
| </asp:DropDownList> |
| </td> |
| </tr> |
| </table> |
| </ContentTemplate> |
| </asp:UpdatePanel> |
| <br /> |
| <table class="tablenav" align="left" border="0" cellpadding="0" cellspacing="0" style="margin-top:10px;margin-left:0px;margin-bottom:0px;width:750px;"> |
| <tr> |
| <td style="width:110px"> </td> |
| <td colspan="3"> |
| <asp:Button ID="btnSave" runat="server" Text="Upload File" CssClass="button100" /> |
| </td> |
| </tr> |
| </table> |
| </td> |
| </tr> |
| </table> |
| <br /> |
| <hr /> |
| </asp:Content> |