MR alaa

MR alaa

  • NA
  • 214
  • 5.1k

C# web browser select list item click

May 27 2016 6:01 AM

hi every body
i have got 3 html drop down list the second drop down get its values on first changed and the third gets its value on second changed how can i pass the values to combox using webbrower control and handle the same thing on combox1 value or index changed the second combox2 set new values and so on the third i had trial this is the html code and my trial ? thanks for all

<pre lang="HTML">



</td>
<td align="right" style="height: 33px" colspan="2">
<select name="DDL1" onchange="javascript:setTimeout('__doPostBack(\'DDL1\',\'\')', 0)" id="DDL1" style="color:Black;font-size:11pt;font-weight:bold;width:340px;border-right: #325a76 1px solid; border-top: #325a76 1px solid;
border-left: #325a76 1px solid; border-bottom: #325a76 1px solid">
<option selected="selected" value="0">select from list </option>
<option value="1">v1 </option>
<option value="2">v2</option>
<option value="4">v3</option>
<option value="5">v4/option>
<option value="6">v5<option>

</select>
</td>

<td align="right" style="height: 33px" colspan="2">
<select name="DDL2" onchange="javascript:setTimeout('__doPostBack(\'DDL1\',\'\')', 0)" id="DDL2" style="color:Black;font-size:11pt;font-weight:bold;width:340px;border-right: #325a76 1px solid; border-top: #325a76 1px solid;
border-left: #325a76 1px solid; border-bottom: #325a76 1px solid">
<option selected="selected" value="0">select from list2 </option>

</select>
</td>

<td align="right" style="height: 33px" colspan="2">
<select name="DDL3" onchange="javascript:setTimeout('__doPostBack(\'DDL3\',\'\')', 0)" id="DDL1" style="color:Black;font-size:11pt;font-weight:bold;width:340px;border-right: #325a76 1px solid; border-top: #325a76 1px solid;
border-left: #325a76 1px solid; border-bottom: #325a76 1px solid">
<option selected="selected" value="0">select from list3 </option>


</select>
</td>

</pre>

i have tried

foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("select"))
{
if (el.Id == "DDL1")
{
foreach (HtmlElement comboItem in el.Children)
{
comboBox1.Items.Add(comboItem.InnerText);
if (comboItem.InnerText == "select from list")
{
comboBox1.SelectedItem = comboItem.InnerText;
}

}
}
}