B
BobRoyAce
There is a web page that I am doing some automation for, using a
WebBrowser on a form. It has a combo box as follows:
<select name="ddlMonth" onchange="javascript:setTimeout('__doPostBack
(\'ddlMonth\',\'\')', 0)" language="javascript" id="ddlMonth"
onkeypress="if (event.keyCode == 13) return false;">
<option selected="selected" value="2/1/2009">February 2009</option>
<option value="1/1/2009">January 2009</option>
</select>
I can easily change the displayed/selected item in the combo box as
follows:
Dim oComboBoxElement As HtmlElement = WebBrowser1.Document.All
("ddlMonth")
For Each oComboBoxItem As HtmlElement In oComboBoxElement.Children
If (oComboBoxItem.GetAttribute("value") = "1/1/2009") Then
oComboBoxItem.SetAttribute("selected", "x")
End If
Next
However, doing it this way, apparently, does not trigger the onchange
event, something I need to do for the automation to work, as the
onchange event fires off code . How can I change the selected item
while, at the same time, triggering the onchange event to fire?
WebBrowser on a form. It has a combo box as follows:
<select name="ddlMonth" onchange="javascript:setTimeout('__doPostBack
(\'ddlMonth\',\'\')', 0)" language="javascript" id="ddlMonth"
onkeypress="if (event.keyCode == 13) return false;">
<option selected="selected" value="2/1/2009">February 2009</option>
<option value="1/1/2009">January 2009</option>
</select>
I can easily change the displayed/selected item in the combo box as
follows:
Dim oComboBoxElement As HtmlElement = WebBrowser1.Document.All
("ddlMonth")
For Each oComboBoxItem As HtmlElement In oComboBoxElement.Children
If (oComboBoxItem.GetAttribute("value") = "1/1/2009") Then
oComboBoxItem.SetAttribute("selected", "x")
End If
Next
However, doing it this way, apparently, does not trigger the onchange
event, something I need to do for the automation to work, as the
onchange event fires off code . How can I change the selected item
while, at the same time, triggering the onchange event to fire?