Sending several input tags with the same name

  • Thread starter Seguros Catatumbo
  • Start date
S

Seguros Catatumbo

Hi guys, i have a question. On old asp, if i did this:

<input type="text" name="myname" value="1">
<input type="text" name="myname" value="2">

asp would make request("myname")="1, 2"

on asp.net, request["myname"] is "1,2" (without the space)

The problem with this is that i am trying to pass multiple currency
values , which have commas inside them. On old asp this wasn't a
problem since i splitted the string with ", " but on asp.net i need to
do "," which of course wouldn't work properly.

Is there a way i can make asp.net use a different separator? Currently
i am employing a hack, replacing the commas with asterisks and then
change then back once read...
 
S

Seguros Catatumbo

I don't know what the advantage of using multiple form elements all with the
same names might be, other than to force you to employ hacks to get around it.
However, the hack you describe seems to work, so "if it ain't broke, don't
fix it".

The advantage is less code.
You can simply split the request variable to an array of strings and
work with them in a simple iteration. If i would use different names
for the variables, it would require more code. Storing objects in the
session or in the viewstate would not be as efficient. Old asp's way
of handling same name input was better IMO
 
M

Mark Rae [MVP]

The advantage is less code.

That's not necessarily better...
You can simply split the request variable to an array of strings and
work with them in a simple iteration. If i would use different names
for the variables, it would require more code.

But less hacking...
Old ASP's way of handling same name input was better IMO
<input type="text" name="myname" value="1">
<input type="text" name="myname" value="2">

Hmm - if you add a new text control between those two, you'd have to give it
a value of 3 - after a while, that would surely get really messy, no...?
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top