0

I am trying to call the jquery uploadify functions from my aspx page. I get this exception when the page loads and $(document).ready is called. It seems that for some reason the FileUpload1 control is not able to call the uploadify function, but I can't tell why. Does this have to do with the control not being in the master page?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="useredit.aspx.cs" Inherits="Dashboard.UserEdit" 
MasterPageFile="~/Masters/Dashboard.master" Title="Profile: Edit " %>

<asp:Content ID="ctHead" ContentPlaceHolderID="cphHead" runat="server">
<link rel="stylesheet" type="text/css" href="/stylesheets/uploadify.css" />
 <style type="text/css">
    .FileUpload1
     {
       font-size:11px;
       color:#5B5B5B;
     }
 </style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js" > </script>
<script language="javascript" type="text/javascript" src='<%# ResolveUrl("~/inc/jquery.uploadify.js") %>' ></script>
<script type="text/javascript">
$(document).ready(function() {
    $('.FileUpload1').uploadify({
        'swf': 'uploadify.swf',
        'uploader': 'TNTUpload.ashx',
        'auto': true,
        'multi': true
    });
});
</script>
</asp:Content>

...

<asp:Content ID="ctBody" ContentPlaceHolderID="cphBody" runat="server">
    <div style = "padding:40px">
        <asp:FileUpload ID="FileUpload1" runat="server"/>
    </div>
</asp:Content>
flerngobot
  • 616
  • 1
  • 9
  • 30
  • 1
    You cannot use `$('#FileUpload1')` to target .net elements. [See here to do it correctly](http://stackoverflow.com/questions/20227170/accessing-asp-net-controls-using-jquery-all-options/20227176#20227176) – Venkata Krishna Dec 24 '13 at 18:03
  • 1
    also check rendered url for `jquery.uploadify.js` possibly its wrong and you simply not load this plugin – Grundy Dec 24 '13 at 18:22
  • wrong selector won't throw error, incorrect file path sounds more lke it. Still need to resolve proper selector though – charlietfl Dec 24 '13 at 18:29
  • thanks for the information on the selectors. I have updated my code to use the css class for the jquery selector, but I'm still getting the same exception thrown. How do I check that the file path is correct? When I comment out the uploadify script (so that the exception isn't thrown), I am able to see that the /inc/jquery.uploadify.js file is included in the head via the DOM explorer. – flerngobot Dec 24 '13 at 18:50
  • Your selector is still wrong. Change `$('.FileUpload1').uploadify({` to `$('#<%= FileUpload1.ClientID %>').uploadify({` – Stephen Dec 25 '13 at 22:54
  • I tried using that type of selector as well, but I got the same error message "Object doesn't support property or method 'uploadify'". – flerngobot Dec 26 '13 at 17:05

1 Answers1

0

The problem here seems to have been caused by already existing jquery scripts in the master page. After I moved the jquery script out of my aspx page and onto the master page the "Object doesn't support property or method..." error went away. I am now having new problems with uploadify having to do with SWF and/or IE, but at least this headache has been resolved.

flerngobot
  • 616
  • 1
  • 9
  • 30