Welcome to the new Uploadify Community Forums. We've made the switch from PHPBB to Vanilla Forums in hopes of controlling the SPAM more efficiently. We hope this change doesn't suck so much. Also, don't forget to wrap your code in tags. You can quickly insert code using ctrl + f.
I lost some messages that were posted on February 4th. If you posted a message or reply on February 4th, please do so again. Sorry about the inconvenience.
Problem with onComplete
  • Hello together...

    I got the following problem:
    If an opload is finished i wanted to update a DropDownList with the Filename.
    So i wrote the following code:

    <script type = \"text/javascript\">
    $(window).load(
    function() {
    $(\"#<%=FileUpload1.ClientID %>\").fileUpload({
    'uploader': '../scripts/uploader.swf',
    'cancelImg': '../scripts/cancel.png',
    'buttonText': 'Upload',
    'script': '../scripts/Upload.ashx',
    'folder': '../uploads',
    'fileDesc': 'Image Files',
    'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
    'multi': true,
    'auto': true,
    'onComplete': function(event, queueID, fileObj, reposnse, data) {
    $('#DropDownList1').append('<asp:ListItem>'+fileObj.name+'</asp:ListItem>');
    }
    });
    }
    );

    </script>

    <asp:FileUpload ID=\"FileUpload1\" runat=\"server\" />

    <asp:DropDownList ID=\"DropDownList1\" runat=\"server\">
    </asp:DropDownList>


    It isn't working, after the upload there aren't any new listitems...! :-/

    Someone got any ideas to fix it? ;-)
    Would be great!

    Btw: Sorry for my bad english, I'm german...

    Greets w3bbY
  • What version of Uploadify are you using?
    What version of ASP.NET are you using?
    Are you using AJAX?

    What I do is simulate an image button click and it works great with AJAX.

    $('#fotoUpload').uploadify({
    'uploader': 'js/uploadify.swf',
    'script': 'scripts/uploader.ashx',
    'cancelImg': 'css/imgs/cancel.png',
    'auto': true,
    'multi': false,
    'folder': '../tmp',
    'buttonImg': 'img/theme/browseupload.png',
    'hideButton': false,
    'rollover': true,
    'height': 21,
    'width': 57,
    'wmode': 'transparent',
    'fileExt': '*.png;*.jpg;*.gif;*.bmp',
    'fileDesc': '*.png;*.jpg;*.gif;*.bmp',
    onError: function(a, b, c, d) {
    if (d.status == 404)
    alert('Could not find upload script.');
    else if (d.type === \"HTTP\")
    alert('error ' + d.type + \": \" + d.status);
    else if (d.type === \"File Size\")
    alert(c.name + ' ' + d.type + ' Limit: ' + Math.round(d.sizeLimit / 1024) + 'KB');
    else
    alert('error ' + d.type + \": \" + d.text);
    },
    onAllComplete: function(e, d) {
    if (d.errors == 0) {
    $('#<%= imgbtnHbtnCompleteFotoUpload.ClientID %>').click();
    return true;
    }
    else {
    return false;
    }
    }
    });



    <input type=\"file\" id=\"fotoUpload\" name=\"fotoUpload\"/>
    <asp:ImageButton ID=\"imgbtnHbtnCompleteFotoUpload\" runat=\"server\" OnClick=\"imgbtnHbtnCompleteFotoUpload_Click\" ImageUrl=\"img/transparentPixel.png\" Width=\"1px\" Height=\"1px\" Style=\"cursor:default\"/>


    In the codebehind you can have something like:
    Protected Sub imgbtnHbtnCompleteFotoUpload_Click(ByVal sender As Object, ByVal e As EventArgs)
    ' Clear dropdownlist and reload dropdownlist.
    End Sub
  • Hello,

    I'm using the newest version of uploadify and ASP.NET 3.5. No Ajax.

    But my code should work i think, but i dont know why it doesn't.
    It is possible to execute this command when upload is complete?

    $('#DropDownList1').append('<asp:ListItem>'+fileObj.name+'</asp:ListItem>');


    If I'm appending a to a like that it's working fine!
    But it must be possible to append a -Elements to a when the upload is completed... not?
  • I think you are doing something wrong with the jquery code
    $('#DropDownList1').append('<asp:ListItem>'+fileObj.name+'</asp:ListItem>');


    At the point onComplete you are using client side script so tag won't work.
    So, google how you can add an option to a select with jQuery. (I don't know it out of my head ;-))
  • Hi iStan,

    great tip! ;-)
    Found the Problem...

    I have to use the following code:

    $(\"#<%=DropDownList1.ClientID %>\").append(\"<option value='1'>\"+fileObj.name+\"</option>\");


    It is working fine as expected!

    Thanks again, you made my day!

    Greets w3bbY
  • Not a problem, I didn't do anything, you solved it yourself ;-) That's a keeper for future projects.
    One thing, watch out for the static value='1' in your code-behind, because with your code all the added files will carry the value='1'.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!