How to get new file name on client side in AsyncFileUpload control in AjaxControlToolkit

Here is a really simple way to get filename on client side after file is uploaded by asyncfileupload control of AjaxControlToolkit.

    <!--This script snippet must be located below the ScriptManager-->
    <script type="text/javascript">
    Sys.Extended.UI.AsyncFileUpload.prototype.newFileName = null;
    function uploadcomplete(sender, e) {
    console && console.log(sender.newFileName);
    <asp:AsyncFileUpload ID="AsyncFileUpload1" OnClientUploadComplete="uploadcomplete"
    runat="server" OnUploadedComplete="AsyncFileUpload1_UploadedComplete" />
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    this.GetType(), "newfile",
    "window.parent.$find('" + AsyncFileUpload1.ClientID + "').newFileName='randomfile.txt';", true);

I have tried this on Ajax Control Toolkit 4.1 and 4.5

Subscribe for our monthly newsletter for updated articles and useful code scripts.

Share It

comments powered by Disqus