469,602 Members | 1,984 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

How can I duplicate the form data?

I want to duplicate the form data, edit it to remove some items (such
as __EVENTTARGET, __EVENTVALIDATION, etc) and save it to a log.

How can I make a duplicate (editable) copy of the Form Collection?

The Form Collection is of type NameValueCollection is, underneath the
covers, an object of type HttpValueCollection.

The problem I have is that my copies have only one key item for a list
(such as a radio button list) whereas the Form has one key per item in
the collection (duplicate keys).

Apart from doing something like:

string aCopy = myForm.ToString();

and then rebuilding the NameValueCollection how can I make an editable
duplicate with duplicate keys for lists?

myForm is passed into a method so:

public void TheHeader(NameValueCollection myForm)
{
...

the calling code is:

SomeClass.TheHeader(Request.Form);

When this happens the resulting myForm is read only.

The code within TheHeader could be:

NameValueCollection nvc = new NameValueCollection();
foreach (string key in myForm)
nvc.Add(key, myForm[key]);

or below which duplicates the above (using the 1st contructor of the
Add method rather than 2nd):

NameValueCollection nvc = new NameValueCollection();
nvc.Add(Request.Form)

No matter how the Form is copied the copy isn't the same because the
original Form has a separate key for each item in a collection (such
as a radio button list). The copy (nvc) will contain only one key
followed by a comma separated value list.

If I serialise it to a string and then use split to put it into an
array how can I be sure that the viewstate and other asp.net fields
won't this up by using the special characters & = , used to delimit
the keys and data?
May 4 '07 #1
2 2292
Just get them all and ignore what you want when dumping to the log file ?

It could be just done in global.asax using the request.form collection (if I
understand what you are trying to do) so that it is easily
changed/removed/added as needed.

(My understanding is that you want just to keep track of posted values in a
server side log.)

"Harry Haller" <Ha***@Steppenwolf.coma écrit dans le message de news:
2c********************************@4ax.com...
>I want to duplicate the form data, edit it to remove some items (such
as __EVENTTARGET, __EVENTVALIDATION, etc) and save it to a log.

How can I make a duplicate (editable) copy of the Form Collection?

The Form Collection is of type NameValueCollection is, underneath the
covers, an object of type HttpValueCollection.

The problem I have is that my copies have only one key item for a list
(such as a radio button list) whereas the Form has one key per item in
the collection (duplicate keys).

Apart from doing something like:

string aCopy = myForm.ToString();

and then rebuilding the NameValueCollection how can I make an editable
duplicate with duplicate keys for lists?

myForm is passed into a method so:

public void TheHeader(NameValueCollection myForm)
{
...

the calling code is:

SomeClass.TheHeader(Request.Form);

When this happens the resulting myForm is read only.

The code within TheHeader could be:

NameValueCollection nvc = new NameValueCollection();
foreach (string key in myForm)
nvc.Add(key, myForm[key]);

or below which duplicates the above (using the 1st contructor of the
Add method rather than 2nd):

NameValueCollection nvc = new NameValueCollection();
nvc.Add(Request.Form)

No matter how the Form is copied the copy isn't the same because the
original Form has a separate key for each item in a collection (such
as a radio button list). The copy (nvc) will contain only one key
followed by a comma separated value list.

If I serialise it to a string and then use split to put it into an
array how can I be sure that the viewstate and other asp.net fields
won't this up by using the special characters & = , used to delimit
the keys and data?

May 4 '07 #2
The following doesn't work either:

NameValueCollection nvc = new NameValueCollection(myForm);

once again the resulting collection has only one key for a radio
button list values rather than a key per entry (as in the original
form).

May 4 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by marx | last post: by
2 posts views Thread by Pablo | last post: by
8 posts views Thread by Ray | last post: by
6 posts views Thread by planetthoughtful | last post: by
6 posts views Thread by Oleg Konovalov | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.