-2

I Can't retrive element while using GetElementby Id in Webbrowser controller; Webpag code is:

<tr class="tb_item02" align="left">
<td width="15%" class="tb_title" align="right">Set as :</td>
<td width="35%">
<select id="set_AS" name="set_AS" class="select">
<option value=""></option>
<option value="Yes">Yes</option>
<option value="No" selected="">No</option>
</select>
</td>

<td width="15%" class="tb_title" align="right">Re-Generate:</td>
<td width="35%">
<select id=" Regenerate" name="Regenerate" class="select">
<option value=""></option>
<option value="Yes">Yes</option>
<option value="No" selected="">No</option>
</select>
</td>
</tr>

As I try to get set_AS Element by:

HtmlElement reportDropDown = wbrsr.Document.GetElementById("set_AS");
HtmlElementCollection elCol = reportDropDown.GetElementsByTagName("option");

reportDropDown stays null and elcol is throwing:

Object reference not set to an instance of an object.

Any suggestion what am I missing here?

Mong Zhu
  • 23,309
  • 10
  • 44
  • 76
DSC
  • 1
  • 2

1 Answers1

-1

Solved :)

Nasted the

HtmlElement reportDropDown = wbrsr.Document.GetElementById("set_AS");
HtmlElementCollection elCol = reportDropDown.GetElementsByTagName("option");

within try snippt, and at the catch event, fired another HtmlElement reportDropDown = wbrsr.Document.GetElementById("set_AS"); HtmlElementCollection elCol = reportDropDown.GetElementsByTagName("option");

DSC
  • 1
  • 2