views:

18

answers:

0

Hi!
I Used AsyncFileUpload(one of Ajac Control Toolkit Controls) to Uploading User's Image. this works well. But i want to change the image url of an image contorl to uploaded image url. how can i perform that? I put Image control in a Update Panel:

<asp:UpdatePanel ID="UpdatePanelNew" runat="server">
    <ContentTemplate>
        <asp:Image ID="Image1" ImageUrl="~/Images/Categories/NoCategory.png" runat="server" />
    </ContentTemplate>
</asp:UpdatePanel>
<asp:AsyncFileUpload OnClientUploadError="uploadError" OnClientUploadComplete="uploadComplete"
    runat="server" ID="AsyncFileUpload1" UploadingBackColor="#CCFFFF" ThrobberID="myThrobber" />
&nbsp;
<asp:Label ID="myThrobber" runat="server" Style="display: none;">
<img align="middle" alt="Working..." src="../../Images/App/uploading.gif" />
</asp:Label>

in C# code I wrote these:

protected void Page_Init()
{
    AsyncFileUpload1.UploadedComplete += new EventHandler<AsyncFileUploadEventArgs>(AsyncFileUpload1_UploadedComplete);
}

void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
{
    ScriptManager.RegisterStartupScript(this, this.GetType(), "size", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';", true);

    string savePath = MapPath("~/Images/Categories/" + Path.GetFileName(e.filename));

    ImageOperations.ResizeFromStream(savePath, 128, AsyncFileUpload1.FileContent);

    Image1.ImageUrl = "~/Images/Categories/" + AsyncFileUpload1.FileName;

    //AsyncFileUpload1.SaveAs(savePath);
}

But it does not work. can you help me?
Note that ImageOperations.ResizeFromStream() method resizes and saves the image to a specefic folder.
actually I should trigger a Postback to Update the Update Panel but How to do that. I used UpdatePanelNew.Update(); but it does not work!