Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I used AsychFileUpload in my asp.net page,

Used the following code to upload

C#
protected void FupFoto_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        System.Threading.Thread.Sleep(5000);
        if (FupFoto.HasFile)
        {
            string strPath = MapPath("~/EmpImages/") + Path.GetFileName(e.filename);
            
            FupFoto.SaveAs(strPath);
            ImgFoto.ImageUrl = strPath;

        }
    }


When executing FupFoto.SaveAs(strPath), I am getting an error, But the file is uploading to the specified folder, But the ImgFoto is not loading with the file

The Error is
"There is no source code available for the current location"

I can't get anything detailed.

Please help me
Posted
Updated 21-Feb-11 18:23pm
v2
Comments
TweakBird 22-Feb-11 0:23am    
Edited for formatting.

Try this.

ImgFoto.ImageUrl = "~/EmpImages/" + Path.GetFileName(e.filename);
 
Share this answer
 
Hi


This error

VB
The Error is
"There is no source code available for the current location"


is due to you are not having a script manager.

As an example...

the aspx content..

XML
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <script type="text/javascript" language="javascript">
            function Test(sender,e) {
                alert("EmpImages/" + e.get_fileName());
                document.getElementById('<%=ImgFoto.ClientID %>').src = "EmpImages/" + e.get_fileName();
            }
         </script>
            <asp:AsyncFileUpload ID="FupFoto" runat="server"   OnClientUploadComplete="Test"      ClientIDMode="AutoID"   OnUploadedComplete="FupFoto_UploadedComplete"/>
            <asp:Image  ID="ImgFoto" runat="server"    ImageUrl=""  />
</asp:Content>



in the upload complete event...

C#
protected void FupFoto_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
    if (FupFoto.HasFile)
    {
        string strPath = MapPath("~/EmpImages/") + Path.GetFileName(e.filename);
        FupFoto.SaveAs(strPath);
    }
}



it should be working in this example
 
Share this answer
 
v2

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



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