473,385 Members | 1,925 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,385 software developers and data experts.

combining dynamic forms with file upload

Hi all,

I've got a form that consists of a bunch of textboxes and also file
upload inputs. For both sets of fields, I need to be able to add in
additional elements on the fly. This is done by an "Add Textbox" and
"Add Upload Fields" button that I use Javascript to add to the fields.
I use client-side Javascript only to add to the fields.

The problem comes when I submit the form. When I submit the form, the
files uploaded present no problems when I use Request.Files. But no
matter what, I can't seem to access the additional textboxes created
by Javascript from my server code. I have tried using FindControl and
Request.Form but both do not work.

One workaround I can think of is to use server-side code to add the
elements by doing a Postback everytime I click on the "Add Textbox"
button, but that would invariably involved uploading the files
selected in the File Upload fields which I want to prevent.

Does anybody know of a better way to do this?

Thanks
Wong
Nov 18 '05 #1
3 2116
Wong,

Have you included the additional textboxes in children property of any of
form controls? They need to belong to form's object hierarchy.
Alternatively, you can prepare all textboxes in advance and just hide/show
them as needed.

Eliyahu

"IRAS Blues" <li*****@yahoo.com> wrote in message
news:d8**************************@posting.google.c om...
Hi all,

I've got a form that consists of a bunch of textboxes and also file
upload inputs. For both sets of fields, I need to be able to add in
additional elements on the fly. This is done by an "Add Textbox" and
"Add Upload Fields" button that I use Javascript to add to the fields.
I use client-side Javascript only to add to the fields.

The problem comes when I submit the form. When I submit the form, the
files uploaded present no problems when I use Request.Files. But no
matter what, I can't seem to access the additional textboxes created
by Javascript from my server code. I have tried using FindControl and
Request.Form but both do not work.

One workaround I can think of is to use server-side code to add the
elements by doing a Postback everytime I click on the "Add Textbox"
button, but that would invariably involved uploading the files
selected in the File Upload fields which I want to prevent.

Does anybody know of a better way to do this?

Thanks
Wong

Nov 18 '05 #2
These elements are inside Web User Control object which is called from
the default form in the web application I'm building. So the hierarchy
is sort of like this:

<form id="defaultForm"> -> <wuc id="defaultUploadForm"> -> <table
id="upLoadTable"> -> <table id="Part_Table"> -> <input
id="Part_Num_*">

Note that the * in Part_Num_* denotes whatever number is generated
when I click on the Add Part button.

using "this.FindControl" in the code behind page for
defaultUploadForm, I seem to be able to call upLoadTable & Part_Table
but I CANNOT seem to access anything inside it, including just any of
its rows e.g. this.upLoadTable.Rows[0].Cells[0].InnerHtml.ToString().
All of them give an object reference error.

What can I be doing wrong here?

Thank you very much...
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:<O4**************@TK2MSFTNGP10.phx.gbl>...
Wong,

Have you included the additional textboxes in children property of any of
form controls? They need to belong to form's object hierarchy.
Alternatively, you can prepare all textboxes in advance and just hide/show
them as needed.

Eliyahu

"IRAS Blues" <li*****@yahoo.com> wrote in message
news:d8**************************@posting.google.c om...
Hi all,

I've got a form that consists of a bunch of textboxes and also file
upload inputs. For both sets of fields, I need to be able to add in
additional elements on the fly. This is done by an "Add Textbox" and
"Add Upload Fields" button that I use Javascript to add to the fields.
I use client-side Javascript only to add to the fields.

The problem comes when I submit the form. When I submit the form, the
files uploaded present no problems when I use Request.Files. But no
matter what, I can't seem to access the additional textboxes created
by Javascript from my server code. I have tried using FindControl and
Request.Form but both do not work.

One workaround I can think of is to use server-side code to add the
elements by doing a Postback everytime I click on the "Add Textbox"
button, but that would invariably involved uploading the files
selected in the File Upload fields which I want to prevent.

Does anybody know of a better way to do this?

Thanks
Wong

Nov 18 '05 #3
"I have tried using FindControl and Request.Form but both do not work."

FindControl:
remember that server-side code is only aware of page content (eg. elements)
that are either created during the initial request or subsequent postback.
So your server-side code will not be aware of any client-side added elements
(eg. <input> tags). Hence, "this.FindControl" will fail to see your new
textboxes.

Request.Form:
Your example indicated an "ID" attribute on the new <input> tag, but did not
include a "name" attribute. If memory serves, the "name" attribute must be
included for an <input> value to be submitted with a form. Further, the
following is quoted from the MSDN library regarding the "name" attribute:

==> The NAME attribute cannot be set at run time on elements dynamically
==> created with the createElement method. To create an element with a
==> name attribute, include the attribute and value when using the
createElement method.

hence the following Javascript should work:

var newTextbox = document.createElement('<input type="text"
name="part_num_11">') ;
[appropriate cell from part_table].appendChild(newTextbox) ;

Hope this helps.

"IRAS Blues" wrote:
These elements are inside Web User Control object which is called from
the default form in the web application I'm building. So the hierarchy
is sort of like this:

<form id="defaultForm"> -> <wuc id="defaultUploadForm"> -> <table
id="upLoadTable"> -> <table id="Part_Table"> -> <input
id="Part_Num_*">

Note that the * in Part_Num_* denotes whatever number is generated
when I click on the Add Part button.

using "this.FindControl" in the code behind page for
defaultUploadForm, I seem to be able to call upLoadTable & Part_Table
but I CANNOT seem to access anything inside it, including just any of
its rows e.g. this.upLoadTable.Rows[0].Cells[0].InnerHtml.ToString().
All of them give an object reference error.

What can I be doing wrong here?

Thank you very much...
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:<O4**************@TK2MSFTNGP10.phx.gbl>...
Wong,

Have you included the additional textboxes in children property of any of
form controls? They need to belong to form's object hierarchy.
Alternatively, you can prepare all textboxes in advance and just hide/show
them as needed.

Eliyahu

"IRAS Blues" <li*****@yahoo.com> wrote in message
news:d8**************************@posting.google.c om...
Hi all,

I've got a form that consists of a bunch of textboxes and also file
upload inputs. For both sets of fields, I need to be able to add in
additional elements on the fly. This is done by an "Add Textbox" and
"Add Upload Fields" button that I use Javascript to add to the fields.
I use client-side Javascript only to add to the fields.

The problem comes when I submit the form. When I submit the form, the
files uploaded present no problems when I use Request.Files. But no
matter what, I can't seem to access the additional textboxes created
by Javascript from my server code. I have tried using FindControl and
Request.Form but both do not work.

One workaround I can think of is to use server-side code to add the
elements by doing a Postback everytime I click on the "Add Textbox"
button, but that would invariably involved uploading the files
selected in the File Upload fields which I want to prevent.

Does anybody know of a better way to do this?

Thanks
Wong

Nov 18 '05 #4

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

Similar topics

2
by: J.R | last post by:
Greetings, I'm adding dynamically created input type='file' controls via JavaScript. However when I try to access they do not seem to be returned in the form collection. Any ideas? Thanks,...
6
by: hsomob1999 | last post by:
so i have a <ul> and I allow the user to append items to it. The problem is that on mozilla the <span class="line"> which is just a line to divide the sections gets overlaped and doesnt move down...
7
by: JavaScriptRocks | last post by:
I've been trying to imitate / reverse engineer the add attachment feature in gmail composer. I managed to do it to say about 80% but its giving me trouble in IE on WinXP-Sp2. I am using PHP to do...
5
by: drdave | last post by:
Hi, I have 6 forms being generated using coldFusion, they are named special1, special2 special3 and so on.. in these forms I have a link to open a new window. I am trying to pickup the...
1
by: devine | last post by:
Hi All, I have a form which checks which Submit button has been pressed and also shows a textarea dependant on an option selected. The problem I have is that when I include my "display text"...
3
by: RahimAsif | last post by:
I am writing an application that requires the a portion of the main menu to be dynamic. The menu has file, panels, view files and help across the top. The view files sub menu needs to be...
5
by: matt | last post by:
hello, i am on an interesting project. in this project, i have to create dynamic data-entry forms for offline-users to fill out, save locally, and eventually postback to our app (when back...
4
by: redoranda | last post by:
hi im a new user here. apparently im working on a project that is creating a dynamic form. Assume user can insert the data into text field and upload csv file, csv file may have two columns. user has...
32
by: phub11 | last post by:
Hi all, This was originally posted on the HTML section, but it was suggested that I post it in the JavaScript section, so here it is... I have a file upload box contained within a form which I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.