By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,852 Members | 888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,852 IT Pros & Developers. It's quick & easy.

Problem in using Request and Request.Form

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Jul 19 '05 #2

P: n/a
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
Jul 19 '05 #3

P: n/a
http://www.aspfaq.com/2111

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


"norton" <no********@hotmail.com> wrote in message
news:O7*************@TK2MSFTNGP11.phx.gbl...
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

Jul 19 '05 #4

P: n/a
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...bom_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.
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.