Simulate a click on the Upload button using javascript

Last post 04-08-2009, 4:59 AM by DarShak_Boy. 2 replies.
Sort Posts: Previous Next
  •  04-02-2009, 10:38 AM 50696

    Simulate a click on the Upload button using javascript

    Hello,
     
    I'm trying to simulate a click on the Upload button using javascript. One version of the code I've tried is this one:
     
    var btnUpload = document.getElementById('ajaxUploader__Insert');
    btnUpload.click();
     
    When I do this, I expect the "Choose file" dialog box to show up (same behaviour as when you click on this button with the mouse). Unfortunately it is not working. This generates a full postback, as if the button is not "bind" to the uploader.
     
    Do you know if this is feasible?
     
    Thanks in advance,
     
    Dar
  •  04-02-2009, 11:24 AM 50699 in reply to 50696

    Re: Simulate a click on the Upload button using javascript

    Dar,
     
    You can try .onclick() insead of the .click():
     
    var uploader=document.getElementById('<%=ajaxUploader.ClientID%>')
    uploader.startbrowse()
     
    for Flash10 , it would show a blocked warning panel.
     
    Regards,
    Terry
     
     
  •  04-08-2009, 4:59 AM 50872 in reply to 50699

    Re: Simulate a click on the Upload button using javascript

    Hello,
     
    Thanks for your answer.
     
    FYI, neither the 'onclick' nor the 'startbrowse' worked for me (guess it has something to do with flash).
    But it's ok because the requirement has changed.

    Regards,
    Dar
View as RSS news feed in XML