Problem in using Request and Request.Form

N

norton

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
 
T

Tarwn

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
 
H

Hans

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
 
D

Dave Anderson

norton said:
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.
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top