473,387 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

JavaScript, ASP, and VB :)

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

Sep 28 '06 #1
1 2769
Jimmy,

There are 3 methods for you, in Net 2.0 you have even the upload method,
that I never used.

http://support.microsoft.com/kb/323245/EN-US/

http://msdn2.microsoft.com/en-us/lib...ileupload.aspx

And with the old request.files("fileid")

I hope this helps,

Cor
"JimmyFo" <ji*****@gmail.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
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

Sep 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.