Asyncfileupload show image after loading without page refresh

I'm already hacking it a bit now, no luck.

Using asyncfileupload control to upload a file and display an image. When loading / updating the page, the termination of loading and the image are displayed.

But you need to know how I can do this without reloading / refreshing the page.

After reading the online posts, I see a recommendation to use the scriptmanager, but this does not work for me:

    protected void FileUploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {

          .
          .
          .
          .

        ScriptManager.RegisterStartupScript(this, GetType(), "TestAlert",
        "window.parent.document.getElementById('" + img_ProfilePic.ClientID + "').src='" + "http://www.site.com/default.jpg" + "');",
        true); 

}

Thanks Behrouz

+3
source share
5 answers

After a few days, right, a few days of debugging, I found that this is an error:

http://ajaxcontroltoolkit.codeplex.com/workitem/26761

I hope this saves other people.

+3
source

, , 554134, , jQuery ( asyncfileupload).

  • AjaxToolkit, ​​, 554134.

  • jQuery, / .

$(document).ready(function () {
            $("#imgConfirmation").hide();
        });

, AsyncFileUpload iframe, jquery "show". :

        function showImage(imagePath) {
            $('#imgConfirmation', window.parent.document).attr("src", imagePath);
            $('#imgConfirmation', window.parent.document).show();
        }
  • UploadedComplete, , script, js. ,
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "showImage", "showImage('" + myLink + "');", true);
+5

JS ScriptManager. , ")" JavaScript, .

, AsyncFileUpload UpdatePanel
http://forums.asp.net/t/1479689.aspx?PageIndex=2

+1

:

protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) 

{ 

string strPath = MapPath("~/upload/") + Path.GetFileName(e.FileName); 

AsyncFileUpload1.SaveAs(strPath); 

displayImage.ImageUrl = strPath; 

} 

JavaScript.

<script type="text/javascript"> 

function uploadComplete(sender, args) { 

var imageName = args.get_fileName(); 

$get("displayImage").src = "./upload/" + imageName; 

} 

</script> 
Hide result

AsyncFileUpload:

detail: https://code.msdn.microsoft.com/How-to-upload-an-image-and-c3703a2c

0

Source: https://habr.com/ru/post/1786081/


All Articles