Problem in using Request and Request.Form

Discussion in 'ASP General' started by norton, Aug 13, 2004.

  1. norton

    norton Guest

    Hi all.

    I have a question in using Request and Request.Form

    when the asp page is Request("txtName")

    i can use "testpage.aspx?txtName=User1" to post the value

    but when i use Request.Form("txtName")
    i cannot use that method,

    what can i do to solve that problem

    (as i cannot modifty the request.form syntax but i need to post data to that
    web page, is there any method so that i can pass that parameter?)

    thx and regards,
    Norton
     
    norton, Aug 13, 2004
    #1
    1. Advertising

  2. norton

    Tarwn Guest

    When you attempt to retrive a value from Request.Form you are specifying that
    you want the system to return a value that was POST'd to the page with that
    name. If your form is using GET (or you are manually bulding the querystring
    value) you would want to use Request.QueryString("aName") to retrieve the
    value.

    The reason using Request("aName") works in either case is because by not
    defining which collection you would like it to look in, it attempts to find
    the first matching key in any of it's collections (.Form, .QueryString,
    ..Cookies, .ServerVariables). Obviously by not specifyingwhich collection you
    would like it to look in you are introducing more overhead because it may
    have to search all four collections to find that the given key doesn't exist.

    -T
     
    Tarwn, Aug 13, 2004
    #2
    1. Advertising

  3. norton

    Hans Guest

    Also be aware that you may step into trouble if you don't specify which
    collection you want to search in if you have a variable with the same name
    (which is of course not good programming practice) in for example both the
    querystring and the form collection. Then it will take the first one in this
    order
    1. Querystring
    2. Form
    3. Cookies
    4. ClientCertificate
    5. Server variables.

    Regards
    /Hans
     
    Hans, Aug 13, 2004
    #3
  4. http://www.aspfaq.com/2111

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "norton" <> wrote in message
    news:...
    > Hi all.
    >
    > I have a question in using Request and Request.Form
    >
    > when the asp page is Request("txtName")
    >
    > i can use "testpage.aspx?txtName=User1" to post the value
    >
    > but when i use Request.Form("txtName")
    > i cannot use that method,
    >
    > what can i do to solve that problem
    >
    > (as i cannot modifty the request.form syntax but i need to post data to

    that
    > web page, is there any method so that i can pass that parameter?)
    >
    > thx and regards,
    > Norton
    >
    >
     
    Aaron [SQL Server MVP], Aug 13, 2004
    #4
  5. norton wrote:
    >
    > i can use "testpage.aspx?txtName=User1" to post the value...


    No, you can't.

    You can PASS a value that way, but POST means something very specific, and
    if you had, in fact, posted such a name-value pair, you wouldn't have the
    following problem:

    > but when i use Request.Form("txtName")
    > i cannot use that method,



    "The Form collection retrieves the values of form
    elements posted to the HTTP request body, with a
    form using the POST method."

    http://msdn.microsoft.com/library/en-us/iissdk/iis/ref_vbom_reqocf.asp


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Aug 13, 2004
    #5
    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:
    894
    Natty Gur
    Jul 29, 2003
  2. Brian Birtle
    Replies:
    2
    Views:
    2,099
    John Saunders
    Oct 16, 2003
  3. George
    Replies:
    5
    Views:
    6,647
    George
    Apr 2, 2004
  4. =?Utf-8?B?ZXN3YW5zb24=?=

    asp.net form to send a request to a put request

    =?Utf-8?B?ZXN3YW5zb24=?=, Oct 29, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    613
    =?Utf-8?B?ZWpz?=
    Nov 9, 2004
  5. John Davis
    Replies:
    2
    Views:
    406
    Dave Anderson
    Aug 18, 2003
Loading...

Share This Page