Topbar
Topbar
Sign in
|
Join
|
Client Center
Home
Products
Client Center
Contact
Purchase
Support forums
»
Products
»
Ajax Uploader
»
Re: Custom UI
Re: Custom UI
03-13-2009, 9:19 PM
cutechat
Joined on 07-22-2004
Posts 2,332
Re: Custom UI
Reply
Quote
Matt
If you do not need show the uploaded list , you should not use UploadAttachments control
Here is a sample to render the custom attachments :
<
%@ Page
Language
=
"VB"
%
>
<
%@ Register
TagPrefix
=
"CuteWebUI"
Namespace
=
"CuteWebUI"
Assembly
=
"CuteWebUI.AjaxUploader"
%
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
script
runat
=
"server"
>
Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
MyBase.OnPreRender(e)
'hide the default table
UploadAttachments1.GetItemsTable()
.Visible
=
False
DataGrid1.DataSource
=
UploadAttachments1
.Items
DataGrid1.DataBind()
End Sub
Protected Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
If
e.CommandName
=
"Download"
Then
Dim guid As
Guid
=
CType
(DataGrid1.DataKeys(e.Item.ItemIndex), Guid)
For Each item As AttachmentItem In UploadAttachments1.Items
If
item.FileGuid
=
guid
Then
Using str As
Stream
=
item
.OpenStream()
Response.AddHeader("Content-Disposition", "attachment;
filename
=" & item.FileName)
Response.AddHeader("Content-Length", item.FileSize)
Dim buff() As
Byte
=
New
Byte(4096) {}
While (True)
Dim rc As
Integer
=
str
.Read(buff, 0, buff.Length)
If
rc
=
0
Then
Exit While
End If
Response.OutputStream.Write(buff, 0, rc)
End While
End Using
End If
Next
End If
End Sub
</
script
>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
>
DataGridVB
</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
CuteWebUI:UploadAttachments
runat
=
"server"
ID
=
"UploadAttachments1"
UploadType
=
Flash
>
</
CuteWebUI:UploadAttachments
>
<
hr
/>
<
asp:DataGrid
ID
=
"DataGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
DataKeyField
=
"FileGuid"
OnItemCommand
=
"DataGrid1_ItemCommand"
>
<
Columns
>
<
asp:BoundColumn
DataField
=
"FileGuid"
HeaderText
=
"File Guid"
/>
<
asp:BoundColumn
DataField
=
"FileName"
HeaderText
=
"File Name"
/>
<
asp:BoundColumn
DataField
=
"FileSize"
HeaderText
=
"File Size"
/>
<
asp:ButtonColumn
CommandName
=
"Download"
Text
=
"Download"
/>
</
Columns
>
</
asp:DataGrid
>
</
div
>
</
form
>
<
script
type
=
"text/javascript"
>
var internalobj;
var
hasprogress
=
false
;
function ShowProgress()
{
if(!internalobj)return;
function ShowIt()
{
internalobj.progressCtrl.style.display
=
""
;
internalobj.progressText.style.display
=
""
;
//if(internalobj.progressText.firstChild.nodeName!="TABLE")
if(!hasprogress)
{
internalobj.progressText.innerHTML
=
"<table border='1' cellspacing=0' cellpadding='1' style='width:360px;border-collapse:collapse;border:1px solid #999999;'>"
+"
<
tr
>
<
td
>
Please select a file
</
td
>
</
tr
>
</
table
>
";
}
}
ShowIt();
setTimeout(ShowIt,10);
}
function CuteWebUI_AjaxUploader_OnInitialize()
{
internalobj
=
this
.internalobject;
ShowProgress();
}
function CuteWebUI_AjaxUploader_OnStart()
{
ShowProgress();
}
function CuteWebUI_AjaxUploader_OnStop()
{
ShowProgress();
}
function CuteWebUI_AjaxUploader_OnProgress(enabled)
{
hasprogress
=
enabled
;
ShowProgress();
}
function CuteWebUI_AjaxUploader_OnQueueUI()
{
ShowProgress();
}
</
script
>
</
body
>
</
html
>
Regards,
Terry
View Complete Thread