unable to access the values of input elements created using javascript

V

Vikram

I have added some input elements on a page using
javascript at client side.
when i submit the page, i am unable to access the values
of input elements created using request.form.
Are elements created using javascript are available at the
server?
if not how can i do the above thing so that there values
can be accessed.
I dont want to postback page everytime i need to create a
new element.
 
J

James Steele

Vikram,

When you create your input elements are you adding the runat="server"
attribute? That should make the control available on the server (I
think). Of course you will have to cast it to the proper type.

Let me know how you make out.
 
V

Vikram

No basically after a page is displyed at client, user can
click a '+" button which will create text box without
posting back to server i.e. using javascript.
After that user will submit the page.....
 
W

William F. Robertson, Jr.

Are you adding the name property of the control? Without the name property
I do believe the element is not considered postable.

<input type="text" name="txtDynamic" />

Request.Forms["txtDynamic"];

bill
 
J

James Steele

Understood. But when that textbox is created you must specify certain
attributes of the input element Such as the name property (as Bill
pointed out). Then if you want to access these WHEN the postback occurs
you will also have to add the runat=server attribute.

Send a code snippet if you like and we can get it you work for you.
 
B

Bruce Barker

you are probably missing the name attribute. try:

in browser:

<script>
document.write('<input type="text" name="myText" value="test value">
</script>

on postback:

sting myValue = Request.Form["myText"];

-- bruce (sqlwork.com)
 
V

Vikram

Thanks a lot.
U were right
-----Original Message-----
you are probably missing the name attribute. try:

in browser:

<script>
document.write('<input type="text" name="myText" value="test value">
</script>

on postback:

sting myValue = Request.Form["myText"];

-- bruce (sqlwork.com)


I have added some input elements on a page using
javascript at client side.
when i submit the page, i am unable to access the values
of input elements created using request.form.
Are elements created using javascript are available at the
server?
if not how can i do the above thing so that there values
can be accessed.
I dont want to postback page everytime i need to create a
new element.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top