473,728 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Text Value of DropDown box

Hi,

I have a drop down as below.

<select id="drp1">
<option value="1">One</option>
<option value="2">Two</option>
</select>
I need the text value of the drop down box.

Request.form("d rp1").value is giving 1 , but I need the value "One". How can
I do this.

Please Help.

Thanks


Apr 19 '06 #1
3 21870

Bhaskar Reddy wrote:
Hi,

I have a drop down as below.

<select id="drp1">
<option value="1">One</option>
<option value="2">Two</option>
</select>
I need the text value of the drop down box.

Request.form("d rp1").value is giving 1 , but I need the value "One". How can
I do this.

Please Help.

Thanks


You could do this:
<select id="drp1">
<option value="One">One </option>
<option value="Two">Two </option>
</select>

Or this:
<select id="drp1">
<option>One</option>
<option>Two</option>
</select>

--
Mike Brind

Apr 19 '06 #2
Bhaskar Reddy wrote:
Hi,

I have a drop down as below.

<select id="drp1">
<option value="1">One</option>
<option value="2">Two</option>
</select>
I need the text value of the drop down box.

Request.form("d rp1").value is giving 1 , but I need the value "One".
How can I do this.

Please Help.

As you have seen, only the value property gets passed via the Request
object.

This is not the first time I've seen this question, and frankly, I'm a
little puzzled by it: aren't you in control of the source of those
value-text pairs? Why can't you simply retrieve the text from the data
source based on the passed value? I suppose you could be using some
client-side data source for the option list ... ?

Anyways, you have a few options:

Make the text be part of the value when populating the options:
<option value="1 - One">One
allowing you to use Split() to retrieve both values from
request.form("d rp1")

Use client-side code to populate a hidden field when the form is submitted
(see a client-side group such as .scripting.jscr ipt for this).

Store the value-text pairs in an xml document on the web server, either in a
file or in a session variable

--
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"
Apr 19 '06 #3
Bob Barrows [MVP] wrote:
This is not the first time I've seen this question, and
frankly, I'm a little puzzled by it: aren't you in control
of the source of those value-text pairs? Why can't you
simply retrieve the text from the data source based on the
passed value?


Or simply: What is the point of a value that differs from the text if you
want the text?

--
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.
Apr 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2386
by: hans.bonefaas | last post by:
Hi all, I hope someone can help me with the following problem in ASP.net. I want to edit the information for a record in a database (MS Access). On the page I placed several textboxes and dropdownlistboxes. In the page_load the information from the database is loaded a dataset. With the following command I place the info from the dataset in the boxes: txtFirstName.Text = ds.Tables(0).Rows(0).Item("FirstName")
2
5712
by: jason | last post by:
hello. i am just trying to save a TextBox.Text value to a database, but strangely, when the value is changed on the web form, the changes are not recognized in the event where i try to save the information. sample.aspx contents: <form id="Form1" method="post" runat="server"> <asp:TextBox id="TextBox1" runat="server" Width="560px" Height="512px" Wrap="True" TextMode="MultiLine"> </asp:TextBox>
8
2858
by: Radek Budaø | last post by:
Hi all, i have trouble with changing text value of textbox on runtime. I use this control to display process information about sending e-mail per smtp. I use external component >>Imports devBiz.Net.Mail which can hadle events by sending mail. >>AddHandler client.OnProgress, AddressOf Progress
5
1815
by: Aussie Rules | last post by:
Hi, Within the code of a content page, how do you say set the .text value of a label thats on the master page.... Thanks
0
1222
by: Tuhin | last post by:
please help me wit the code of passing hyperlink1.text value with navigateurl property of the hyperlink. cannot use session variable as cannot trap the value for non availability of the onClick() methode. the NavigateUrl='<%# "Main.aspx?Page_Number=" & Hyperlink1.Text %>' stuff not happening. Tell me if I am going wrong. Cannot use Get DATA VALUE also as cannot trap the hyperlink1.text value.
3
3567
nirmalsingh
by: nirmalsingh | last post by:
i have loaded a set of array values dynamically in text box from a database like this: //Response.Write("<input type=text value="+stredit+">");// then i have kept a save button: //Response.Write("<input type=button value=Save >");// ---------------------------------------------------------------------------------------------------------------- UPTO THIS WORKING WELL. now i want to alter the data in text and save to database. i just want...
8
3905
by: Raul | last post by:
Hi, I have a select list that gets populated from the DB. When the user makes a selection I am able to retrieve this value via Request.Form(...) However, I am wondering if you can retrieve the text value using ASP?? I know this can be done in JavaScript using the options text attribute, but it is possible in ASP?
0
1098
by: Jabba007 | last post by:
I have an update trigger on a table called 'tbl_br' that is used to audit column changes and populate those changes into an audit table called 'tbl_audit'. See an excerpt of the code below: Declare @LoginId as nvarchar (8) set @LoginId = dbo.fnGetLoginId() Declare @status_id_new int Declare @id_old as int Declare @status_id_old int
7
3582
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR Me.cboLocation.Text = ""
0
8903
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9198
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6013
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4792
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3236
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2663
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2161
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.