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

Get a Single Selection's Name from a Dropdown box

2 Answers 72 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nate
Top achievements
Rank 1
Nate asked on 25 Apr 2011, 08:39 PM
Hello I'm trying to store the string text from a dropdown's boxes menu(of type ArtOfTest.WebAii.Controls.HtmlControls.HtmlSelect) programmatically. If I convert the box's InnerText to a string it will result in a single string with all of the items in the dropdown box as a single word. Is there anyway I can get this information for a single entry?

2 Answers, 1 is accepted

Sort by
0
Nate
Top achievements
Rank 1
answered on 25 Apr 2011, 08:44 PM
Basically the HTML looks like this-

<SELECT id=ctrlDropDown name=ctrlEdit:DropDown1><OPTION value=1111>TargetText1</OPTION><OPTION value=1234>ExampleText2</OPTION><OPTION value=2222>SampleText3</OPTION>

Where I want to extract the value "TargetText1" and/or "ExampleText2" and store it as a string.
0
Dobry Zranchev
Telerik team
answered on 27 Apr 2011, 03:49 PM
Hi Nate,

Thank you for writing.

If you want to write the items' texts you can you the following code snipped in the coded step.
foreach(HtmlOption option in Pages.YourPage.CtrlDropDownSelect.Options)
{
    Log.WriteLine(option.Text);
}
This code will write the following rows in the Log file.
'4/27/2011 11:21:55' - LOG: TargetText1
'4/27/2011 11:21:55' - LOG: ExampleText2
'4/27/2011 11:21:55' - LOG: SampleText3

In case that you have other related questions, feel free to contact us.

Best wishes,
Dobry Zranchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Nate
Top achievements
Rank 1
Answers by
Nate
Top achievements
Rank 1
Dobry Zranchev
Telerik team
Share this question
or