Skip to content
Loading
OnUploadedComplete not firing  
  • "width:100%;">  
  • "dlImages" runat="server" RepeatColumns="0" RepeatDirection="Horizontal" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3">  
  • "#DCDCDC" />  
  • "#CCCCCC" ForeColor="Black" />  
  • "#000084" Font-Bold="True" ForeColor="White" />  
  • "#EEEEEE" ForeColor="Black" />  
  •   
  • "0" style="width:100%;border-bottom-color:#60BAEA;border-top-color:#60BAEA;border-left-color:#60BAEA;border-left-color:#60BAEA;" cellspacing="5">  
  •   
  • "center" style="padding:5px;width:100%;">  
  • "img" runat="server" align="center" BorderStyle="Solid" BorderColor="#e0ddd7" BorderWidth="1" Height="50" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "IMAGE_PATH") %>' />  
  •   
  • "RemoveLinkBtn" runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "IMAGE_ID") %>' OnCommand="RemoveLinkBtn_Command" >Remove  
  •   
  •   
  •   
  •   
  • "#008A8C" Font-Bold="True" ForeColor="White" />  
  •   
  •   
  •   
  • "btnViewGallery" runat="server" Text="View Gallery" OnClick="btnViewGallery_Click" /> 
      
  •   
  •   
  •   
  • Code :
    1. #region Ajax Upload File  
    2. protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)  
    3. {  
    4. string filePath = string.Empty;  
    5. try  
    6. {  
    7. string strID = Session["selectedid"].ToString();  
    8. int compid = Convert.ToInt32(Session["COMPID"]);  
    9. filePath = (Server.MapPath("~/fileupload/gallery/") + Guid.NewGuid() + System.IO.Path.GetFileName(e.FileName));  
    10. AjaxFileUpload1.SaveAs(filePath);  
    11. string strFile = filePath.Substring(filePath.LastIndexOf("\\"));  
    12. string strFileName = strFile.Remove(0, 1);  
    13. string strFilePath = "~/fileupload/gallery/" + strFileName;  
    14. string input = Server.MapPath("fileupload/gallery/") + strFileName;  
    15. string thumb = Server.MapPath("fileupload/gallery/thumb/") + strFileName;  
    16. string output = Server.MapPath("fileupload/gallery/display/") + strFileName;  
    17. // Load image.  
    18. System.Drawing.Image image = System.Drawing.Image.FromFile(input);  
    19. Size thumbnailSize = GetImageSize(image, 110);  
    20. System.Drawing.Image thumbnail = resizeImage(image, thumbnailSize);  
    21. thumbnail.Save(thumb);  
    22. Size displaySize = GetImageSize(image, 640);  
    23. System.Drawing.Image display = resizeImage(image, displaySize);  
    24. display.Save(output);  
    25. // Compute thumbnail size, Get thumbnail & Save thumbnail.  
    26. /*  
    27. Size thumbnailSize = GetImageSize(image,110);  
    28. System.Drawing.Image thumbnail = image.GetThumbnailImage(thumbnailSize.Width,  
    29. thumbnailSize.Height, null, IntPtr.Zero);  
    30. thumbnail.Save(thumb);  
    31. }  
    32. catch (Exception ex)  
    33. {  
    34. Response.Write(ex.Message.ToString());  
    35. }  
    36. }  
    37. #endregion  

    1 Reply

    Know the answer? Post it — somebody with the same question will find it here.