We help IT Professionals succeed at work.
Get Started

displaying an image inside an updatepanel

COHFL asked
Last Modified: 2012-05-09
hi all,
I have a little bit of a problem. I want to change the display of an asp:image after some code gets execute. in a nutshell what i'm trying to do is upload an image using AsyncFileUpload. So far everything works from the initial image displaying after the upload but the last display of the image uploaded does not work.
Can any one guide me here?
see the code below
<asp:UpdatePanel ID="UpdatePanel1" 
                <asp:AsyncPostBackTrigger ControlID="AsyncFileUpload1" EventName="UploadedComplete" />
                            <br />
                        <asp:Image ID="imgHolder" runat="server" />
                            <br />
                        <asp:Label ID="lblStatus" runat="server" Style="font-family: Arial; 
	                        font-size: small;">
	                    <asp:Label ID="Throbber" runat="server" Style="display: none">
                            <img src="Images/indicator.gif" align="absmiddle" alt="loading" />
                            <br />
            <cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server" 
              CompleteBackColor="#FFFFCC" ErrorBackColor="Red" 
              OnClientUploadComplete="UploadComplete" OnClientUploadError="uploadError" 
              onuploadedcomplete="AsyncFileUpload1_UploadedComplete" ThrobberID="Throbber" 
              UploadingBackColor="#66CCFF" Width="450px" UploaderStyle="Modern" />

code behind

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        imgHolder.ImageUrl = "images/Helpme.gif"
 End Sub

 Protected Sub AsyncFileUpload1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs)
            If Not System.IO.Directory.Exists(Server.MapPath("./") & "Request/Entries/" & Me.EntryHolder.Value) Then
                System.IO.Directory.CreateDirectory(Server.MapPath("./") & "Request/Entries/" & Me.EntryHolder.Value)
            End If
            If AsyncFileUpload1.HasFile Then
                Dim fileName As String = Server.MapPath("./") & "Request/Entries/" & Me.EntryHolder.Value & "/" & Me.AsyncFileUpload1.FileName
                'ScriptManager.RegisterClientScriptBlock(Me.AsyncFileUpload1, Me.AsyncFileUpload1.[GetType](), "img", "top.document.getElementById('imgHolder').src='" & Server.MapPath("./") & "Request/Entries/images.jpg';", True)
                Me.imgHolder.ImageUrl = "Request/Entries/HW03091000007/Conversion010810.JPG"
            End If

        Catch ex As Exception
            Throw ex.InnerException
        End Try

    End Sub

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE