Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
A certain application I am wanting to write has a client requirement to not pass strings with periods in them back to the database from a CascadingDropDown, but do show the period in the box on the screen.

So easy enough, in my web service I have it return a CascadingDropDownNameValue object with the name with periods and the values without.

Now, say I want to access the "names" i.e., the text showing in the dropdown box on screen, from JavaScript, i.e.

ddlModel.options[ddlModel.selectedIndex].text;


I know I can get the "value" i.e., the text "behind" the dropdown by using

ddlModel.options[ddlModel.selectedIndex].value;


but I don't want the "value" I want the displayed "text." However the line

ddlModel.options[ddlModel.selectedIndex].text;


isn't giving me the text that has the period in it, like I want. Any hints?

Brian
Posted

1 solution

Have you tried with JQuery?

$("#ddlModel:selected").text();


or

$("[id$='ddlModel'] :selected").text()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900