Problem retrieving value via Request.Form

C

Chico

Hi,

I have the following code in my form:

Response.Write("<form name='Testing'>");
Response.Write("<INPUT type=hidden id='Testing_txtbox'
name='Testing_txtbox' value='a simple test'>");
Response.Write("</form>");

If I type the following in the very next line, I get a value of
"undefined".

Response.Write("value="+Request.Form("Testing_txtbox"));

Can anyone tell me why this won't work. If it can't can anyone tell
me how I can retrieve values of hidden controls via Server side code?

Thanks
 
R

Ray Costanzo [MVP]

That value won't exist in the Request.Form collection until it is posted by
the client back to the server. "<input type=hidden..." is merely a string
that is being sent back in the response. It has no ties to Request.Form.
That comes from when the visitor of your page submits a form. Then the form
collection will have something called Testing_txtbox.

Ray at work
 
P

Patrice

Add method="post" to your form tag. By default it uses the GET method (ie
uses the querystring) and the form collection is empty...

(you'll likely have also to change the logic as this value is available only
once the user entered something and submitted the form, not during the
initial display).

Patrice
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top