reading text of select box from users selection

Posted on 2004-03-25
Last Modified: 2012-05-04
i have a simple html selectbox and i can read the selected value no problem. How do i read the text?

something like this?
Request.Form["AFFX"].SelectedIndex.Text ?

im having a complete brain fart today
Question by:tmueller18
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 33

Expert Comment

ID: 10679103
try this

LVL 33

Expert Comment

ID: 10679124
html selectbox?

Author Comment

ID: 10679140
the error

Compiler Error Message: CS0246: The type or namespace name 'AFFX' could not be found (are you missing a using directive or an assembly reference?)

im using HTML to build the selectbox

<select name='Afil1'>
    <option value="">- Please select affiliate -</option>
    <option value="5517">ABC Affiliate</option>
    <option value="5487">adsfdsfasdfffdddfd</option>
    <option value="5512">Affiliate ABC</option>
    <option value="5515">Affiliate test x</option>
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.


Author Comment

ID: 10679258
i huess i could do something like this

<option value="5517_ABC Affiliate">ABC Affiliate</option>

and then parse out the name from the value.

would I use indeOf in c# for this?

LVL 33

Expert Comment

ID: 10679331
try this piece of code.



<script language="JavaScript">
function getValue() {

function getText() {


<form name="frmMain">
<select name="mysel">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>

<input type="button" value="Get Value" onclick="getValue()">
<input type="button" value="Get Text" onclick="getText()">


LVL 33

Expert Comment

ID: 10679335
javascript will solve your problem.

Author Comment

ID: 10679893
i need this one the server side since items are going into a database

Accepted Solution

ClydeBalneaves earned 500 total points
ID: 10702518
I presume you're ASP.NET?

If so, you need to use .NET controls for serverside, and not just HTML.


--.aspx file---
<asp:DropDownList id="dropDown" runat="server" Width="176px">
      <asp:ListItem Value="1">one</asp:ListItem>
      <asp:ListItem Value="2">two</asp:ListItem>

--.aspx.cs file---
protected System.Web.UI.WebControls.DropDownList dropDown;

Then you can access it like a normal control :




If you have to use just plain HTML, then I guess setting the value the same as the text is the easiest way to go, if not the only way.

Not sure how much you know about ASP.NET, but remember its served to the user as plain HTML, the code above is purely serverside.

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question