Uploading Images with Image List refresh (Update UpdatePanel)

Feb 5, 2009 at 4:37 PM
Seems there has been a few posts on this. Basically I want to upload Files and have the list of files refresh to show the updated list. I would have though this was a fairly straight forward idea. However there seems to be no documentation on how to do a page refesh or databind when the file upload is complete.

I assumed the onfilereceived would have been the event to use, ie assign a databind on this event. I can assign a throw new exception and nothing happens.
I cannot get this to refresh the list of files after new files have been uploaded.

Here is the code I have been using:

<%

@ Page Language="VB" %>

 

 

 

<%

@ Register Assembly="com.flajaxian.FileUploader" Namespace="com.flajaxian" TagPrefix="cc1" %>

 

 

 

 

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

 

 

<

script runat="server">

 

 

 

 

 

Protected Sub Repeater1_Load(ByVal sender As Object, ByVal e As System.EventArgs)

 

 

 

    Dim DI As New System.IO.DirectoryInfo(Server.MapPath("/slideshow/Home/"))

 

 

    Dim DT As New System.Data.DataTable()

 

 

 

    DT.Columns.Add(

"FileName")

 

    

Dim DR As System.Data.DataRow

 

 

 

    

For Each FI As System.IO.FileInfo In DI.GetFiles

 

 

 

        DR = DT.NewRow
        DR(

"FileName") = "/slideshow/Home/" & FI.Name

 

 

 

        DT.Rows.Add(DR)

 

 

 

    Next

 

 

    Repeater1.DataSource = DT

    Repeater1.DataBind()

    DT =

Nothing

 

     

 

    DR =

Nothing

 

     

 

    DI =

Nothing

 

End Sub

 

 

 

Protected Sub FileUploader1_FileReceived(ByVal sender As Object, ByVal e As com.flajaxian.FileReceivedEventArgs)

 

    Repeater1.DataBind()

 

 

End Sub

 

</

script>

 

 

<

html xmlns="http://www.w3.org/1999/xhtml">

 

 

<

head runat="server">

 

 

 

 

<title>Untitled Page</title>

 

</

head>

 

 

<

body>

 

 

    <form id="form1" runat="server">
        <
div>
            
<asp:ScriptManager ID="ScriptManager1" runat="server">

 

 

            </asp:ScriptManager>

 

 

 

 

            <asp:UpdatePanel ID="UpdatePanel1" runat="server">

 

 

                <ContentTemplate>

 

 

                    <asp:Repeater ID="Repeater1" runat="server" OnLoad="Repeater1_Load">

 

 

                        <ItemTemplate>

 

 

                            <img alt="" border="0" src='/SlideImage.aspx?W=200&amp;FPath=<%# Eval("FileName") %>'>

 

 

                        </ItemTemplate>

 

                    </asp:Repeater>
                   
<cc1:FileUploader ID="FileUploader1" UseInsideUpdatePanel="true" runat="server" 

 

 

                      TransparentBackground="true" onfilereceived="FileUploader1_FileReceived">

 

                        <Adapters>

 

 

                            <cc1:FileSaverAdapter FolderName="slideshow\Home\" />

 

 

                        </Adapters>

 

                    </cc1:FileUploader>

 

                </ContentTemplate>

 

 

            </asp:UpdatePanel>

 

 

        </div>

 

 

    </form>
</
body>

 

</

html>

Feb 5, 2009 at 4:39 PM
p.s. The formatting is fine in VS2008, I guess codeplex needs to update their wysiwyg editor, it messed up all my formatting.
Coordinator
Feb 6, 2009 at 3:19 PM
Well page refresh when upload is finished is super easy:

 <script>
function FileStateChanged(uploader, file, httpStatus, isLast){
    Flajaxian.fileStateChanged(uploader, file, httpStatus, isLast);
    if(isLast){
           document.location.href = document.location.href;
    }
}
</script>

<fjx:FileUploader JsFunc_FileStateChanged="FileStateChanged" runat="server" >
    <Adapters>
        <fjx:FileSaverAdapter Runat="server" FolderName="UploadFolder" />
    </Adapters>
</fjx:FileUploader>
Feb 7, 2009 at 2:00 AM
That was absolutely marvelous, I know its more work, but that should be in the documentation, or stickied in the forum. So many people have asked for that, and it would have been a show stopper without it.

Again, thanks a million.

Tod