J
JimmyFo
Hi, this is a bit complicated but maybe someone can help here. I have
an ASP.Net 2.0 page with a JavaScript file selector. I did this because
I wanted to be able to select multiple files at a time. Here's a quick
preview of the JS and ASP to show you what it looks like:
ASP
<td style="width:30%"><asp:FileUpload ID="fileBox" runat="server" />
<asp:Button ID="grabFile" Text="Submit" runat="server"
/></td>
<td style="width:70%">
<div id="files_list"></div></td>
JAVASCRIPT
function initFileUpload(){
//Create an instance of the multiSelector class, pass it the output
target and the max number of files
var multi_selector = new MultiSelector( document.getElementById(
'files_list' ), 5 );
//Pass in the file element
multi_selector.addElement( document.getElementById( 'fileBox' ) );
}
....
....
/**
* Add a new file input element
*/
this.addElement = function( element ){
....
// Add reference to this object
element.multi_selector = this;
// What to do when a file is selected
element.onchange = function(){
if(!element.block)
{
element.block = true;
// New file input
var new_element = document.createElement( 'input' );
new_element.type = 'file';
// Add new element
this.parentNode.insertBefore( new_element, this );
// Apply 'update' to element
this.multi_selector.addElement( new_element );
// Update list
this.multi_selector.addListRow( this );
....
/**
* Add a new row to the list of files
*/
this.addListRow = function( element ){
// Row div
var new_row = document.createElement( 'div' );
// Delete button
var new_row_button = document.createElement( 'input' );
new_row_button.type = 'button';
new_row_button.value = 'Delete';
// References
new_row.element = element;[/code]
Now, what I would like to do is to get that list of elements (I can
store it as an array in one variable if need be) in the VB codebehind
on that button click. Is there a way to do that? When the button is
clicked, I need to access that JS filelist/array and bring it into the
VB codebehind.
Any help is apprecaited!
Thanks,
James
an ASP.Net 2.0 page with a JavaScript file selector. I did this because
I wanted to be able to select multiple files at a time. Here's a quick
preview of the JS and ASP to show you what it looks like:
ASP
<td style="width:30%"><asp:FileUpload ID="fileBox" runat="server" />
<asp:Button ID="grabFile" Text="Submit" runat="server"
/></td>
<td style="width:70%">
<div id="files_list"></div></td>
JAVASCRIPT
function initFileUpload(){
//Create an instance of the multiSelector class, pass it the output
target and the max number of files
var multi_selector = new MultiSelector( document.getElementById(
'files_list' ), 5 );
//Pass in the file element
multi_selector.addElement( document.getElementById( 'fileBox' ) );
}
....
....
/**
* Add a new file input element
*/
this.addElement = function( element ){
....
// Add reference to this object
element.multi_selector = this;
// What to do when a file is selected
element.onchange = function(){
if(!element.block)
{
element.block = true;
// New file input
var new_element = document.createElement( 'input' );
new_element.type = 'file';
// Add new element
this.parentNode.insertBefore( new_element, this );
// Apply 'update' to element
this.multi_selector.addElement( new_element );
// Update list
this.multi_selector.addListRow( this );
....
/**
* Add a new row to the list of files
*/
this.addListRow = function( element ){
// Row div
var new_row = document.createElement( 'div' );
// Delete button
var new_row_button = document.createElement( 'input' );
new_row_button.type = 'button';
new_row_button.value = 'Delete';
// References
new_row.element = element;[/code]
Now, what I would like to do is to get that list of elements (I can
store it as an array in one variable if need be) in the VB codebehind
on that button click. Is there a way to do that? When the button is
clicked, I need to access that JS filelist/array and bring it into the
VB codebehind.
Any help is apprecaited!
Thanks,
James