Best way to get FORM variables?

  • Thread starter Thread starter brett
  • Start date Start date
B

brett

On a postback, what is the best way to get FORM variables so that there
is a key/value structure that allows accessing by key name. For
example:

INSERT INTO table1 (keys['columnone'], keys['columntwo'])
values (keys['columnone'].value, keys['columntwo'].value)

I need to keep keys and values synchronized and call by variable name.
I'm currently doing:

NameValueCollection coll=Request.Form;

and access keys this way in a for loop
coll.Keys

then another for loop for the values. I need more control however.
Meaning accessing by variable name.

Thanks,
Brett
 
On a postback, what is the best way to get FORM variables so that there
is a key/value structure that allows accessing by key name.

Is this because you are building the form dynamically so that, at postback,
you don't know the number of web controls...?

Generally speaking, there's no need to use Request.Form in ASP.NET - that's
very much legacy ASP usage...
 
This is a regular HTML form. There aren't any ASP.NET controls on the
page. I'm using PayPal and the form it sends back has variables I sent
but may have other variables PayPal adds. I need to check by variables
name to avoid breaking the sproc.
 
This is a regular HTML form. There aren't any ASP.NET controls on the
page. I'm using PayPal and the form it sends back has variables I sent
but may have other variables PayPal adds. I need to check by variables
name to avoid breaking the sproc.

Oh right - you didn't mention any of that in your OP...

No matter - presumably you're talking abount IPN / PDT here...? I have a
method for this which uses WebRequest and WebResponse which gets round this
issue completely.

However, you can certainly walk through the Request.Form collection and
extract the keys and their values:
http://authors.aspalliance.com/aspxtreme/sys/web/httprequestclassform.aspx
 
No matter - presumably you're talking abount IPN / PDT here...? I have a
method for this which uses WebRequest and WebResponse which gets round this
issue completely.

However, you can certainly walk through the Request.Form collection and
extract the keys and their values:http://authors.aspalliance.com/aspxtreme/sys/web/httprequestclassform...

Ok, Request.Form[ "controlName" ] is all I need than.

Can you send me the method you use for IPN?

Thanks,
Brett
 
Back
Top