Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Reading dropdown values in ASP

Reply
Thread Tools

Reading dropdown values in ASP

 
 
Martin Walke
Guest
Posts: n/a
 
      03-29-2007
Hi all,

I have an ASP application where I need to not only read the selected item
from a combo box on a web page but also all the options in the combo box.
Can someone point me in the right direction.

I can obviously use request.querystring() or request.form() to get the
selected value but not sure about how to get the options.

TIA
Martin


 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      03-29-2007
Martin Walke wrote:
> Hi all,
>
> I have an ASP application where I need to not only read the selected
> item from a combo box on a web page but also all the options in the
> combo box. Can someone point me in the right direction.
>
> I can obviously use request.querystring() or request.form() to get the
> selected value but not sure about how to get the options.
>

Obviously, you have to store the values somewhere that is accessible to the
code running on the web server. Possibilities inclued a database, a text
file, an xml file, a session variable, an application variable, or some
combination of the above.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      03-29-2007
Martin Walke wrote:
> Hi all,
>
> I have an ASP application where I need to not only read the selected
> item from a combo box on a web page but also all the options in the
> combo box. Can someone point me in the right direction.
>
> I can obviously use request.querystring() or request.form() to get the
> selected value but not sure about how to get the options.
>

Oh! One possibility i neglected to mention was to use a hidden field in
the form to store the option values, making them part of the Request.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
Tim Slattery
Guest
Posts: n/a
 
      03-29-2007
"Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote:

>Hi all,
>
>I have an ASP application where I need to not only read the selected item
>from a combo box on a web page but also all the options in the combo box.
>Can someone point me in the right direction.
>
>I can obviously use request.querystring() or request.form() to get the
>selected value but not sure about how to get the options.


You can't. When the form is submitted, one value is transmitted for a
select group: the "value" attribute of the selected option. Nothing
else is sent.

If you want to know the other options in the select group, you'll have
to do it another way: store them in a database, in the session object,
something like that. And bear in mind, that what's transmitted for the
selected option is not what the user sees, it's the "value" attribute.

--
Tim Slattery
MS MVP(DTS)
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://members.cox.net/slatteryt
 
Reply With Quote
 
Martin Walke
Guest
Posts: n/a
 
      03-29-2007
Thanks Bob.

My line of thinking was to a hidden field anyway.

I just wondered, although couldn't find any reference to it, whether the
srever could access the data in some sneaky way. Obviously, if I'd thought
it through, that client side data doesn't get transmitted in the Request.

Martin

"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Martin Walke wrote:
>> Hi all,
>>
>> I have an ASP application where I need to not only read the selected
>> item from a combo box on a web page but also all the options in the
>> combo box. Can someone point me in the right direction.
>>
>> I can obviously use request.querystring() or request.form() to get the
>> selected value but not sure about how to get the options.
>>

> Oh! One possibility i neglected to mention was to use a hidden field in
> the form to store the option values, making them part of the Request.
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>



 
Reply With Quote
 
Martin Walke
Guest
Posts: n/a
 
      03-29-2007
Thanks Tim. It was as I assumed. As per my comment to Bob, I'll use a hidden
field populated by my validate routine.

Martin


"Tim Slattery" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote:
>
>>Hi all,
>>
>>I have an ASP application where I need to not only read the selected item
>>from a combo box on a web page but also all the options in the combo box.
>>Can someone point me in the right direction.
>>
>>I can obviously use request.querystring() or request.form() to get the
>>selected value but not sure about how to get the options.

>
> You can't. When the form is submitted, one value is transmitted for a
> select group: the "value" attribute of the selected option. Nothing
> else is sent.
>
> If you want to know the other options in the select group, you'll have
> to do it another way: store them in a database, in the session object,
> something like that. And bear in mind, that what's transmitted for the
> selected option is not what the user sees, it's the "value" attribute.
>
> --
> Tim Slattery
> MS MVP(DTS)
> (E-Mail Removed)
> http://members.cox.net/slatteryt



 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
1 Gridview. Dropdown A is column from database, Dropdown B is column from database, Data in A and B must be from same row. anonymoushamster@gmail.com ASP .Net 2 11-07-2007 12:40 PM
ajax cascading dropdown: second dropdown disabled acadam ASP .Net 0 12-27-2006 10:59 AM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
Select dropdown box bleeds into Javascript dropdown menu Mike HTML 1 12-18-2003 09:49 PM
Edit Mode - How do I populate dropdown in edittemplate from dropdown in another column? Steve Myers ASP .Net Datagrid Control 2 11-20-2003 01:09 PM



Advertisments