Problem retrieving value via Request.Form

Discussion in 'ASP General' started by Chico, Jun 3, 2005.

  1. Chico

    Chico Guest

    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
    Chico, Jun 3, 2005
    #1
    1. Advertising

  2. 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

    "Chico" <> wrote in message
    news:...
    > 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
    >
    Ray Costanzo [MVP], Jun 3, 2005
    #2
    1. Advertising

  3. Chico

    Patrice Guest

    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

    --

    "Chico" <> a écrit dans le message de
    news:...
    > 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
    >
    Patrice, Jun 3, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian H
    Replies:
    1
    Views:
    871
    Natty Gur
    Jul 29, 2003
  2. Praveen
    Replies:
    6
    Views:
    4,622
    Praveen
    Mar 1, 2005
  3. Kai Grossjohann
    Replies:
    2
    Views:
    800
    Anton Spaans
    Dec 8, 2003
  4. Chris Shipley

    Trouble retrieving value with request.form

    Chris Shipley, Jan 12, 2004, in forum: ASP General
    Replies:
    1
    Views:
    158
    Aaron Bertrand [MVP]
    Jan 12, 2004
  5. Replies:
    3
    Views:
    162
    Michael Winter
    Nov 8, 2004
Loading...

Share This Page