Topbar
Topbar
Sign in
|
Join
|
Client Center
Home
Products
Client Center
Contact
Purchase
Support forums
»
Products
»
Ajax Uploader
»
Custom Items Table Before Upload
Custom Items Table Before Upload
09-05-2011, 10:44 PM
joshmikow
Joined on 09-06-2011
Posts 2
Custom Items Table Before Upload
Reply
Quote
I'm currently evaluating the use of the AJAX Uploader for a VB.Net project I'm working on in Visual Studio 2010 and .Net 4.0 using codebehind files.
So far I've got the upload working fine, but I need to be able to customize the ItemTable before the actual upload takes place.
The requirements of my application are:
1. Allow user to select multiple files to upload
2. Require user to enter in a description of each file PRIOR to upload to server
3. Allow user to check an optional checkbox to convert the file once uploaded.
4. If possible, I'd like to show the user a thumbnail of the photo so they can accurately describe it, before uploading.
5. Have the user click a button to upload the files and show a progress bar per file
6. Preferable the file would be uploaded directly as a Stream or Byte array so we can store it in our EDMS and not have to worry about temporary files.
My issue seems to be that after selecting files, the GetItemsTable remains visible and I can't figure out why or how to get it to allow me to add the additional fields. I've tried an ItemTemplate but it doesn't show up. I've also tried having it display a custom GridView with additional data but that is only showing up after I click the Submit button.
Here's the code I'm currently using:
Protected
Overloads
Overrides
Sub
OnPreRender(
ByVal
e
As
EventArgs)
MyBase
.OnPreRender(e)
SubmitButton.Attributes(
"itemcount"
) = Uploader1.Items.Count.ToString()
'hide the default table
Uploader1.GetItemsTable().Visible =
False
DataList1.DataSource = Uploader1.Items
DataList1.DataBind()
End
Sub
Private
Sub
InsertMsg(
ByVal
msg
As
String
)
ListBoxEvents.Items.Insert(0, msg)
ListBoxEvents.SelectedIndex = 0
End
Sub
Private
Sub
SubmitButton_Click(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Handles
SubmitButton.Click
InsertMsg(
"You clicked the Submit Button."
)
InsertMsg(
"You have uploaded "
& uploadcount &
"/"
& Uploader1.Items.Count &
" files."
)
End
Sub
Private
uploadcount
As
Integer
= 0
Private
Sub
Uploader_FileUploaded(
ByVal
sender
As
Object
,
ByVal
args
As
UploaderEventArgs)
Handles
Uploader1.FileUploaded
uploadcount += 1
InsertMsg(
"File uploaded! "
& args.FileName &
", "
& args.FileSize &
" bytes."
)
Dim
streamFile
As
Stream = args.OpenStream
'upload to EDMS using stream object
End
Sub
<
%@ Page
Language
=
"vb"
AutoEventWireup
=
"false"
CodeBehind
=
"Testing.aspx.vb"
Inherits
=
"ezEvidence.Testing"
%
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
>
</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
cutewebui:uploadattachments
runat
=
"server"
ManualStartUpload
=
"true"
ID
=
"Uploader1"
InsertText
=
"Browse Files"
TempDirectory
=
"~/UploaderTemp"
DialogFilter
=
"Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF"
showfileicons
=
"true"
showprogressbar
=
"true"
ItemTemplatePosition
=
"BeforeText"
>
<
ItemTemplate
>
<
asp:TextBox
ID
=
"txtDescription"
runat
=
"server"
>
</
asp:TextBox
>
<
asp:CheckBox
ID
=
"cbResizeNetRMS"
runat
=
"server"
/>
</
ItemTemplate
>
</
cutewebui:uploadattachments
>
<
asp:Button
runat
=
"server"
ID
=
"SubmitButton"
OnClientClick
=
"return submitbutton_click()"
Text
=
"Submit"
/>
<
br
/>
<
div
>
<
asp:GridView
ID
=
"gvUploadItems"
runat
=
"server"
AutoGenerateColumns
=
"False"
DataKeyNames
=
"FileGuid"
>
<
Columns
>
<
asp:BoundField
DataField
=
"FileGuid"
HeaderText
=
"File Guid"
/>
<
asp:BoundField
DataField
=
"FileName"
HeaderText
=
"File Name"
/>
<
asp:BoundField
DataField
=
"FileSize"
HeaderText
=
"File Size"
/>
<
asp:ButtonField
CommandName
=
"Remove"
Text
=
"Remove"
/>
<
asp:ButtonField
CommandName
=
"Download"
Text
=
"Download"
/>
</
Columns
>
</
asp:GridView
>
</
div
>
<
asp:DataList
ID
=
"DataList1"
runat
=
"server"
>
<
ItemTemplate
>
<
table
border
=
"1"
>
<
tr
>
<
td
>
<
%# Eval("FileName") %
>
</
td
>
<
td
>
<
%# Eval("FileSize") %
>
</
td
>
<
td
>
<
%# Eval("FileGuid") %
>
</
td
>
</
tr
>
</
table
>
</
ItemTemplate
>
</
asp:DataList
>
<
br
/>
<
div
>
Server Trace:
<
br
/>
<
asp:ListBox
runat
=
"server"
ID
=
"ListBoxEvents"
Width
=
"400"
>
</
asp:ListBox
>
</
div
>
<
script
type
=
"text/javascript"
>
function submitbutton_click() {
var
submitbutton
=
document
.getElementById('
<
%=SubmitButton.ClientID %
>
');
var
uploadobj
=
document
.getElementById('
<
%=Uploader1.ClientID %
>
');
if (!window.filesuploaded) {
if (uploadobj.getqueuecount()
>
0) {
uploadobj.startupload();
}
else {
var
uploadedcount
=
parseInt
(submitbutton.getAttribute("itemcount")) || 0;
if (uploadedcount
>
0) {
return true;
}
alert("Please browse files for upload");
}
return false;
}
window.filesuploaded
=
false
;
return true;
}
function CuteWebUI_AjaxUploader_OnPostback() {
window.filesuploaded
=
true
;
var
submitbutton
=
document
.getElementById('
<
%=SubmitButton.ClientID %
>
');
submitbutton.click();
return false;
}
</
script
>
</
form
>
</
body
>
</
html
>
Any suggestions on how to make this work are greatly appreciated. If I can get this working I can then recommend that we purchase the AJAX Uploader component to use within our application.
Thanks,
Josh
View Complete Thread