Click here to Skip to main content
15,883,769 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i use ajax file uploader:

XML
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
  </asp:ToolkitScriptManager>
  <div>
      <asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server"
          onuploadedcomplete="AsyncFileUpload1_UploadedComplete" />
      <asp:Image ID="Image1" runat="server" />
  </div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>


At Code Behind:

C#
AsyncFileUpload1_UploadedComplete
{
string path = Server.MapPath("~/Upload/") + e.FileName;
        AsyncFileUpload1.SaveAs(path);

        Image1.ImageUrl= "~/Upload/" + e.FileName;
 Label1.Text="/Upload/"+ e.FileName;

}


But Image is not shown in image1 control,
and label1 also not shown any text:

so what can i do:
i want that, when user upload image, then with out refresing page,
image is show in Image1 control,

I think that when UploadedComplete Event called it not refress full page,so image and label is blank
Posted
Updated 8-Mar-13 0:55am
v6
Comments
ZurdoDev 7-Mar-13 8:44am    
Have you viewed the source of the image after it is rendered? Is the url correct? You may need to wrap the ImageUrl part in ResolveClientUrl()
Check whether image exists or not in folder "Upload" ?
Then see if the path you are referring (~/Upload/) is correct or not ?
Arun kumar Gauttam 7-Mar-13 13:23pm    
code is right, and i also have image in my folder,
but i think when i upload image using ajax file uploader,
it not refresh full page because i am not use any button to upload file

1 solution

Sounds like it is a relative path issue.

There is a method exposed to handle URL's. Have a read: ResolveUrl[^].

I would suggest you to use this Tip and resolve the path correctly before setting the control/image source: Resolving Paths in a Multi-Folder WebSite[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900