Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > In order?

Reply
Thread Tools

In order?

 
 
Paulo Roberto
Guest
Posts: n/a
 
      12-26-2007
Hi, I have a html form with a lot of fields in a such order, but when
retrieved by

for each key in request.form
response.write key & " - " & request.form(key) & "<BR>"
next

it lists them all out of order, how could I do a logic to get all of them on
the same order that was put on html?

example if I have:

Name
Address
Age
Birthday
Postal code
etc

the for each doesnt get on the order above... I need to send them via email
and must be on the same html order... can you help me?

Thanks!!!


 
Reply With Quote
 
 
 
 
daddywhite
Guest
Posts: n/a
 
      12-26-2007
On 26 Dec, 18:34, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
com> wrote:
> retrieve them individually and reassemble in the order desired.


I have done this before but cant access the code right now - think it
is something like below:

for i = 1 to Request.Form.Count
for each name in Request.Form
if Request.Form(name) = Request.Form(i) then
ADD TO EMAIL BODY
end if
Next
Next
 
Reply With Quote
 
 
 
 
Dave Anderson
Guest
Posts: n/a
 
      12-27-2007
Paulo Roberto wrote:
> Hi, I have a html form with a lot of fields in a such order, but
> when retrieved by
>
> for each key in request.form
> response.write key & " - " & request.form(key) & "<BR>"
> next
>
> it lists them all out of order, how could I do a logic to get all
> of them on the same order that was put on html?


You can't do it in ASP. The HTML specification *does* require it for
building the form data set...

"The control names/values are listed in the order they appear in the
document."

http://www.w3.org/TR/html401/interac...ml#h-17.13.4.1


"The parts are sent to the processing agent in the same order the
corresponding controls appear in the document stream."

http://www.w3.org/TR/html401/interac...ml#h-17.13.4.2


....but the Request.Form collection is still a collection, and therefore
subject to this:

"Unlike arrays, collections expand and contract automatically as
items are retrieved or stored. The position of an item will
also move as the collection is modified."

http://msdn2.microsoft.com/en-us/library/ms525228.aspx

I presume the collection re-orders as it is being filled with your form
data.



--
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.


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      12-27-2007
"Paulo Roberto" <> wrote in message
news:OH1xlt%...
> Hi, I have a html form with a lot of fields in a such order, but when
> retrieved by
>
> for each key in request.form
> response.write key & " - " & request.form(key) & "<BR>"
> next
>
> it lists them all out of order, how could I do a logic to get all of them

on
> the same order that was put on html?
>
> example if I have:
>
> Name
> Address
> Age
> Birthday
> Postal code
> etc
>
> the for each doesnt get on the order above... I need to send them via

email
> and must be on the same html order... can you help me?
>


I can't reproduce this problem. The underlying object return by
Request.Form is an implementation of IRequestDictionary. As far as I'm
aware this it is not a sorting dictionary so keys should be returned in the
original order that they were inserted.

Use www.fiddlertool.com to capture the form POST and examine the order of
fields being sent. In my IE6 and IE7 testing this appears to behave as per
the spec Dave as point to.

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57