This is a migrated thread and some comments may be shown as answers.

Obtain value of combobox in script

6 Answers 71 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Alan T
Top achievements
Rank 1
Alan T asked on 07 May 2010, 12:15 PM
Very simple scenario here,

Got 2 Combobox's when either of them change value, i want a label to display the value.

Without a postback, so js / ajax


6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 May 2010, 12:42 PM

Hello,

You can attach the 'OnClientSelectedIndexChanged' event to RadComboBox and get the selecteditem text in the client event handler using  "eventArgs.get_item().get_text()" method, then show the value in label text.

You can find out more client side methods of RadComboBox object here:

Client-Side Basics

RadComboBox object

-Shinu.

0
Alan T
Top achievements
Rank 1
answered on 07 May 2010, 05:36 PM
Hi Shinu,

I can get the value ok, but am struggling to set a label's value to it.

                 var county = document.getElementById("<%= lbl_countrydisplay.ClientID %>");
                 country.set_text = text


Tried something like that, also tried your standard JS funcitons like .value
0
robertw102
Top achievements
Rank 1
answered on 07 May 2010, 08:33 PM
If you want to the set the value in the label it would go like this:

country.innerHTML = value;
0
Alan T
Top achievements
Rank 1
answered on 09 May 2010, 01:41 AM
yeah tried that, that changes on the screen, but if i try access it server side it still has the old value. Ie, i need to do something with the value of the label server side and doing label.text isn't returning the updated value.
0
sitefinitysteve
Top achievements
Rank 2
Veteran
answered on 09 May 2010, 04:54 PM
Does this do anything?
0
Accepted
Schlurk
Top achievements
Rank 2
answered on 11 May 2010, 04:16 PM
Alan,

This is more of a general ASP.NET Ajax issue, but basically what you are setting as the label's text via javascript is not being persisted to the code-behind. One way to address this would be to take use of hidden fields and set their value equal to what you just set the label's innerHTML equal to. An example of this can be found in this ASP.NET forum thread.
Tags
ComboBox
Asked by
Alan T
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Alan T
Top achievements
Rank 1
robertw102
Top achievements
Rank 1
sitefinitysteve
Top achievements
Rank 2
Veteran
Schlurk
Top achievements
Rank 2
Share this question
or